Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
Solra Bizna

[MC1.7.10][OC1.5.x]ARM Architecture "OC-ARM" (alpha, updated 2016-06-07)

Recommended Posts

So. just for the purpose of catching up. the program you are send me to is a program that you made to simulate OC-ARM so i don't need to compile the code anymore. if so this is wonderful information because my computers are f-[CENSORED]-ing POSSESSED they never wanna work for me. not even when i set everything up just perfect. i will download this tomorrow maybe (sooner if you can tell me how to get an African Grey Parrot down from a tree (but this is off subject)). thanks for the suggestion to QEMU. i at the same time of learning how to program for this mod decided if i am going to go halfway why not go all the way and just learn the ISA completely and not just what i need to know to skate by. so i was  looking for a spot to start a Hello, World! script without having to find the hardware. thanks for making the simulator this will be VERY helpful

Share this post


Link to post
Share on other sites

So. just for the purpose of catching up. the program you are send me to is a program that you made to simulate OC-ARM so i don't need to compile the code anymore.

That depends on which code you mean. You still need to compile whatever ROM and/or program you're running, but you won't have to start up Minecraft and get things copied over just to do basic testing.

Also, I haven't posted the simulator yet, just a couple of screenshots. The simulator itself will be posted shortly after I finish the painstaking process of debugging every single floating point instruction used by Lua so I know which ones are breaking everything. (So close...)

 

sooner if you can tell me how to get an African Grey Parrot down from a tree

Move its cage outside, place treats inside the cage, and wait some distance from the cage. (Assuming this is a pet parrot trying to become a former pet parrot.)

Share this post


Link to post
Share on other sites

ok, thanks for saving me time from trying to figure out why your package won't install. glad i checked here first. and yes the parrot is my pet he flew out and flew 1/4 mile from my house. then stopped. during my search today i am 95% sure i saw him flying back though. fingers crossed i did.

 

when you release your package will it be a download from here or a terminal download like apt-get (idk what it is for which ever linux you use.)

 

 

upon reviewing my reply and your posts i figured out where i got confused thanks for the reference to gcc-arm-none-eabi. i believe this will help me out ALOT

Share this post


Link to post
Share on other sites

Do I need any special gcc if I am compiling on an ARM machine? Or will normal gcc work for me, cus when I compile your jarmrom I get fatal error: 'sys/cdefs.h' file not found cdefs.h is for x64 and x86 architecture right?

Share this post


Link to post
Share on other sites

Gorzoid. i am getting the same error, i have been trying to fix it and not really getting anywhere in doing so. at least i think i am getting the same error that you are so i will post my error and you can agree with me or not. but i can not figure out where this error is coming from

Compiling src/test.c...
In file included from src/test.c:2:
In file included from /usr/lib/llvm-3.8/bin/../lib/clang/3.8.0/include/inttypes.h:26:
In file included from /usr/include/inttypes.h:25:
/usr/include/features.h:367:12: fatal error: 'sys/cdefs.h' file not found
#  include <sys/cdefs.h>
           ^
1 error generated.
GNUmakefile:38: recipe for target 'obj/test.o' failed
make: *** [obj/test.o] Error 1

at first i thought maybe it was a small error in my ways but with your post. ik its something more then me. thanks for you post

Share this post


Link to post
Share on other sites

Building the ROMs on an ARM machine should work. As an added bonus, you'll have a version of GDB that can make use of core dumps made by OC-ARM or its simulator.

It's weird that it's picking up inttypes.h but not cdefs.h. Future releases from me won't suffer from this issue, because they'll use newlib's headers and ignore system ones. Until then, I think that problem can be fixed by installing the appropriate kernel headers package. (e.g. the linux-kernel-headers package on Debian or Ubuntu)

If that doesn't work, I'll post instructions for building newlib and modifying my Makefiles to use it. That'll solve the header problems once and for all.

(For what it's worth, none of this should prevent you from building pure-assembly programs; try "make bin/tetris.rom" or "make bin/boot0.rom")

Share this post


Link to post
Share on other sites

ok, thanks i will make sure to install said packages. i think we are getting close to being able to compile it on our parts. i will get back to you by editing this post.

 

 

well, i was really hoping that would work, thanks for the link i am sure it will help me out in the future but as of right now it did not fix the problem. can't wait for the newlib release.

Share this post


Link to post
Share on other sites

Okay, then, until the next release here's what you can do.

Pick a directory to put all of these things into. (For me, because I'm lazy and disorganized, it's my home directory.) Download the newlib source code and unpack it there. Make a new directory called "newlib-jarm-build" next to the "newlib-2.4.0" directory, change to it, and do:

../newlib-2.4.0/newlib/configure --target arm-none-eabi --disable-multilib --disable-newlib-register-fini --disable-newlib-mb --disable-newlib-wide-orient --enable-lite-exit --disable-newlib-iconv --disable-newlib-supplied-syscalls --prefix=`pwd` CC="clang" CFLAGS="-g -target armv7a-eabi -march=armv7-a -mfloat-abi=hard -mbig-endian -mhard-float -mfpu=vfpv4 -mhwdiv=thumb,arm -ccc-gcc-name arm-none-eabi-gcc"
make -k
Don't forget the "-k" for make. The make command will spit out errors and appear to fail, but enough of newlib to use will in fact have been built.

Then move the "jarmrom" directory next to those directories, and edit GNUmakefile. On the CFLAGS line, where it says:

-Iinclude/
change it to say:

-nostdlibinc -isystem include/ -isystem ../newlib-jarm-build/ -isystem ../newlib-2.4.0/newlib/libc/include/
Then it should finally build, independent of whatever header packages you have installed, independent of whether you're on a Mac or a Linux box or Cygwin or an ancient Sun workstation running NeWS.

It's worth mentioning that the boot0 code I released had a minor bug where it never closed its file handle. This shouldn't cause any significant problems, or I'd post the fix immediately. The next release will not have this problem.

(The work debugging individual FPU instructions continues, slowly, excruciatingly...)

Share this post


Link to post
Share on other sites

ok, THANKS! i will make sure to try this as soon as possible on my mac right now i am on mobile so can't really try it to well. i am going to try and get a boot loader running so you don't have to focus both sides of the code (unless you want to). i figured you seem to have the outside part down so i will try my hardest to get the inside part down. how ever i can try to help with the outside part if needed although not much preferred at this point in time. thanks for the help catching the rest of us up with you. 

Share this post


Link to post
Share on other sites

well. i am trying to just Hello, World! but and it seemed easy enough on X86 (For X86 Hello world is just a few lines)so i figured that Hello World would be almost identical. any suggestions other then Hello World. i also think i need to learn how to make a Makefile, seems important. i figured that a boot loader just had to point to one spot on the drive and start executing. but i after reviewing your code i realized i didn't even think about half the things that your boot loader handles. I thought earlier above you said that 0.2a broke any existing boot loader. i guess you fixed it

Share this post


Link to post
Share on other sites

because ik nothing of make i am doing what i am told. for thge first step do i do --build, --host, or --target? hope to here back soon.

 

P.S. Just noticed your sig. its very straight and to the point. it works well

Share this post


Link to post
Share on other sites

well. i am trying to just Hello, World! but and it seemed easy enough on X86 (For X86 Hello world is just a few lines)

Hello World in x86 assembly is "simple" only when you can call out to the operating system to do simplified IO. There isn't an OS to speak of right now for OC-ARM, so a Hello World program has to:
  • Initialize its own memory (only if it's a ROM rather than an ELF loaded by a bootloader)
  • Get the address of a GPU
  • Get the address of a screen
  • Bind the GPU to the screen
  • Set appropriate colors
  • Call gpu:set(...) to display a message on the screen
  • Sleep indefinitely, and/or handle raw signals
For what it's worth, this job is much easier on OC-ARM than it would be on a typical microcontroller. OC-ARM's IO system is clunky, but (arguably) breezy compared to setting up a UART and feeding it bytes.

A good starting point to look for examples relevant to "Hello World" would be RAMless Tetris. I meant to do an ELF version of that to demonstrate the differences between the two, but I haven't gotten around to that yet. It does all of the above (and a fair bit more), and I think at least half of it is commented. :)

 

i also think i need to learn how to make a Makefile, seems important.

The jarmrom Makefile is designed to be (relatively) simple to modify to have your own programs in there. First, add bin/yourprogramname.elf to the "all: " line. Lower down, below the bin/%.elf rule, add something like:

bin/yourprogramname.elf: src/yourprogramname.ld obj/yourprogramname.o obj/startup.o
Copy src/test.ld to src/yourprogramname.ld. (Unless you're doing something weird, or running out of stack space, you won't have to modify the ld script.)

Create src/yourprogramname.s in your favorite text editor.

	.text
	.code 32

	.global main
	.func main
main:
	/* Your code goes here */
	.endfunc
Now when you type "make", your program will be among the programs built. Or, you can do "make bin/yourprogramname.elf" and it will make only that program. (This is useful if you still haven't gotten test.elf compiling, for instance.)

 

I thought earlier above you said that 0.2a broke any existing boot loader. i guess you fixed it

0.0a2 broke code that was written for 0.0a1. The code I released was for 0.0a2, so anything you build from that will work, including the boot0 bootloader.

 

for the first step do i do --build, --host, or --target?

I don't understand this question.

Share this post


Link to post
Share on other sites

Sorry yes. That is a very indescript question isnt it. When i tried the newlib fix it said one the first step i needed to do one of thoose three options the. Erroree out just after it created config.log

Share this post


Link to post
Share on other sites

What error message does it give? If you give me the config.log I can take a look at what's going on.

(And again, if all you want to build is assembly programs like boot0, you don't need to get the C compiler part working at all.)

Share this post


Link to post
Share on other sites

i wanna focus on making a rom file. but i would also like to write ELF files in the near future so i would like to have a working compiler for it. also you keep bringing up a bin folder, do you mean the one in the jarmrom folder. if you do then i need to re-dowload it because there is nothing in there.

 

Here you are good sir

 ../newlib-2.4.0/newlib/configure --target arm-none-eabi --disable-multilib --disable-newlib-register-fini --disable-newlib-mb --disable-newlib-wide-orient --enable-lite-exit --disable-newlib-iconv --disable-newlib-supplied-syscalls --prefix=`pwd` CC="clang" CFLAGS="-g -target armv7a-eabi -march=armv7-a -mfloat-abi=hard -mbig-endian -mhard-float -mfpu=vfpv4 -mhwdiv=thumb,arm -ccc-gcc-name arm-none-eabi-gcc"

configure: WARNING: you should use --build, --host, --target
configure: WARNING: invalid host type: projects/new-lib-jarm/newlib-jarm-build
checking build system type... Invalid configuration `projects/new-lib-jarm/newlib-jarm-build': machine `projects/new-lib-jarm/newlib-jarm' not recognized
configure: error: /bin/sh ../newlib-2.4.0/newlib/../config.sub projects/new-lib-jarm/newlib-jarm-build failed

sorry to keep coming at you with these errors. like i said i have no experience with make. when i did my attempt at hello world on X86 i just told nasm to do its thing

 

edit: oops forgot the config.log its a long one instead of me posting it is a spoiler i figured pastbin would be better: here

Share this post


Link to post
Share on other sites

You have a space in one of the directory names in that path. That will cause problems with some older / poorly written tools. Putting quotes around `pwd` (to make "`pwd`") might fix the immediate problem, but run into another problem of the same type farther down. Try it and see. (If it works, I'll update my notes.)

Share this post


Link to post
Share on other sites

YES IT WORKED. thanks that was the problem. i have got a compiled version of newlib now to finish the setup. thanks. totally didnt see that causing the problem. thanks

wow you where right make -k spits out a couple tons of errors. i dont think i have ever seen that many

 

I wish i could give you good news and say that it worked 100% through and through and i am sorry that i just keep bringing back error after error and i do apologize for it

 

Compiling src/test.c...
src/test.c:143:16: error: unknown token in expression
  asm volatile("CDP p3, 5, cr0, cr0, cr0, #0\n\t"
               ^
<inline asm>:1:28: note: instantiated into assembly here
        CDP p3, 5, cr0, cr0, cr0, #0
                                  ^
src/test.c:143:47: error: invalid operand for instruction
  asm volatile("CDP p3, 5, cr0, cr0, cr0, #0\n\t"
                                              ^
<inline asm>:2:6: note: instantiated into assembly here
        STC p3, c3, big_buffer(%rip)
            ^~~
src/test.c:14:18: error: unknown token in expression
    asm volatile("CDP p7, 0, cr0, cr0, cr0, #0" :;
                 ^
<inline asm>:1:28: note: instantiated into assembly here
        CDP p7, 0, cr0, cr0, cr0, #0
                                  ^
src/test.c:16:18: error: invalid instruction mnemonic 'mcr'
    asm volatile("MCR p7, 0, %0, cr0, cr0" :: "r"(codepoint));
                 ^
<inline asm>:1:2: note: instantiated into assembly here
        MCR p7, 0, %edx, cr0, cr0
        ^
src/test.c:14:18: error: unknown token in expression
    asm volatile("CDP p7, 0, cr0, cr0, cr0, #0" :;
                 ^
<inline asm>:1:28: note: instantiated into assembly here
        CDP p7, 0, cr0, cr0, cr0, #0
                                  ^
src/test.c:16:18: error: invalid instruction mnemonic 'mcr'
    asm volatile("MCR p7, 0, %0, cr0, cr0" :: "r"(codepoint));
                 ^
<inline asm>:1:2: note: instantiated into assembly here
        MCR p7, 0, %eax, cr0, cr0
        ^
src/test.c:14:18: error: unknown token in expression
    asm volatile("CDP p7, 0, cr0, cr0, cr0, #0" :;
                 ^
<inline asm>:1:28: note: instantiated into assembly here
        CDP p7, 0, cr0, cr0, cr0, #0
                                  ^
src/test.c:14:18: error: unknown token in expression
    asm volatile("CDP p7, 0, cr0, cr0, cr0, #0" :;
                 ^
<inline asm>:1:28: note: instantiated into assembly here
        CDP p7, 0, cr0, cr0, cr0, #0
                                  ^
src/test.c:16:18: error: invalid instruction mnemonic 'mcr'
    asm volatile("MCR p7, 0, %0, cr0, cr0" :: "r"(codepoint));
                 ^
<inline asm>:1:2: note: instantiated into assembly here
        MCR p7, 0, %eax, cr0, cr0
        ^
src/test.c:16:18: error: invalid instruction mnemonic 'mcr'
    asm volatile("MCR p7, 0, %0, cr0, cr0" :: "r"(codepoint));
                 ^
<inline asm>:1:2: note: instantiated into assembly here
        MCR p7, 0, %r15d, cr0, cr0
        ^
src/test.c:14:18: error: unknown token in expression
    asm volatile("CDP p7, 0, cr0, cr0, cr0, #0" :;
                 ^
<inline asm>:1:28: note: instantiated into assembly here
        CDP p7, 0, cr0, cr0, cr0, #0
                                  ^
src/test.c:16:18: error: invalid instruction mnemonic 'mcr'
    asm volatile("MCR p7, 0, %0, cr0, cr0" :: "r"(codepoint));
                 ^
<inline asm>:1:2: note: instantiated into assembly here
        MCR p7, 0, %eax, cr0, cr0
        ^
src/test.c:16:18: error: invalid instruction mnemonic 'mcr'
    asm volatile("MCR p7, 0, %0, cr0, cr0" :: "r"(codepoint));
                 ^
<inline asm>:1:2: note: instantiated into assembly here
        MCR p7, 0, %eax, cr0, cr0
        ^
src/test.c:16:18: error: invalid instruction mnemonic 'mcr'
    asm volatile("MCR p7, 0, %0, cr0, cr0" :: "r"(codepoint));
                 ^
<inline asm>:1:2: note: instantiated into assembly here
        MCR p7, 0, %eax, cr0, cr0
        ^
src/test.c:16:18: error: invalid instruction mnemonic 'mcr'
    asm volatile("MCR p7, 0, %0, cr0, cr0" :: "r"(codepoint));
                 ^
<inline asm>:1:2: note: instantiated into assembly here
        MCR p7, 0, %edx, cr0, cr0
        ^
src/test.c:16:18: error: invalid instruction mnemonic 'mcr'
    asm volatile("MCR p7, 0, %0, cr0, cr0" :: "r"(codepoint));
                 ^
<inline asm>:1:2: note: instantiated into assembly here
        MCR p7, 0, %edx, cr0, cr0
        ^
src/test.c:172:7: error: invalid instruction mnemonic 'mrc'
  asm("MRC p3, 0, %0, cr0, cr2":"=r"(cpu_speed);
      ^
<inline asm>:1:2: note: instantiated into assembly here
        MRC p3, 0, %eax, cr0, cr2
        ^
src/test.c:175:16: error: invalid operand in inline asm: 'MRRC p3, 0, $0,
      ${0:H}, cr0'
  asm volatile("MRRC p3, 0, %0, %H0, cr0":"=r"(clock);
               ^
src/test.c:175:16: error: unknown token in expression
<inline asm>:1:20: note: instantiated into assembly here
        MRRC p3, 0, %rsi, , cr0
                          ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
GNUmakefile:41: recipe for target 'obj/test.o' failed
make: *** [obj/test.o] Error 1

 

at first i thought this could be a problem with the way i set up binutils (I assumed we still need that? ) so i reconfigured it and made sure configured it and made sure it was set to ARM-linux and then went back into jarmrom incomplete and the other one and got identical errors. i got lost in some of these. is it really what it seems. just code syntax errors? if

Share this post


Link to post
Share on other sites

What version of clang are you running? "clang --version" will let you find out.

Also, since you're on your Mac again, you'll have to modify the makefile slightly. Only the first few lines. Those tell it where to find the appropriate versions of those utilities. You should change the ones that say "arm-none-eabi-<tool>" to whatever the full path to the <tool> binary is. For example, mine would be:

AS=/home/sbizna/nobackup/binutils-gdb/gas/as-new
CC=clang
CXX=clang++
LD=/home/sbizna/nobackup/binutils-gdb/ld/ld-new
OBJCOPY=/home/sbizna/nobackup/binutils-gdb/binutils/objcopy
OBJDUMP=/home/sbizna/nobackup/binutils-gdb/binutils/objdump
(Your binutils source directory will probably not be named binutils-gdb.)

Share this post


Link to post
Share on other sites

So before i attempt it. I need to fix mac by pointing straight to binutile then if possible update clang,". Ok sounds easy enough (last words)

I was going to ask how you knew I was on mac. Then I remembered i posted the term code... I am slow today

 

i am running clang 703.0.29 

Share this post


Link to post
Share on other sites

for the sake of pure communication when i do sudo make install (i did a clean install under the directory where i have the mod and newlib) i get an error that says 'sbrk' deprecated

 

you want me to replace arm-none-eabi with the directory to binutils/gas/as-new? or just as?

 

then the rest of it seems straight forward. just wanted to clarify 

Share this post


Link to post
Share on other sites

The "make install" step is actually not necessary if you modify the jarmrom makefile to point to the compiled tools in-tree. In fact, it might do more harm than good by getting in the way of the native tools. I'm not sure.

You'll need to replace every arm-none-eabi-<tool> with the path to the compiled tool, whether in-tree or where it gets installed by "make install", either way.

I'm not sure how that version number maps to mainline clang; my clang is reasonably recent, and reports its version as 3.5. Since a lot of ARM assembly related stuff was added/improved 3.5, I suspect earlier versions won't work.

Share this post


Link to post
Share on other sites

Ok, After some digging i finally found where binutils installed to. it installed into Xcode.app all the way in the back of the program it took some looking but i found it so now i need to replace arm-none-eabi with its path, the only thing thats got me now is that there is no onjcopy or obj dump- that i can see though. the directory that i found the file is was /Applicatoins/Xcode.app/Contents?Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin i don tthink i have the wrong directory because it has LD and AS in it, do you want me to post a screen shot? I FEEL WE ARE GETTING REALLY CLOSE

 

 

 

HOLD THE PHONE!

ok, after some checking i found out that binutils did not successfully install onto my mac, surprise! (just my luck). i have no remote clue why. same thing i did on my mac i did to my linux and it worked out just fine. i have attempted to install binutils version 2.26 there are a few errors but it still went on so i ignored them.thte only error i was it complaining because sbrk was deprecated.

 

the spiel of information that clang gives me when i ask it for a version is

Apple LLVM version 7.3.0 (clang-703-0-29)

Target: X86_64-apple-darwin15.4.0

Thread model: poix

Installed Directory: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchains/usr/bin

 

this version of clang came with Xcode. should i upgrade it. its late over here and my brain has stopped working.

 

it might be worth it for me to try your work around up top can you explain a little bit more. i think i am mis-understanding by overthinking what your asking me to do up there

if you modify the jarmrom makefile to point to the compiled tools in-tree

How does one do this ^^^^

 

i am going to take a small break when we get this part working, it has confused me and blown my fuses up top. but hey it'll be worth it because then i can apply what i learn in this mod (almost) directly to one of my projects i have been trying to do (i had NO clue that in order to right a program for arm it would require this. this is going to end up being more then my hobby.)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.