dafna
Posts: 9
Joined: Wed Dec 20, 2017 6:55 pm

uart04 in bare metal examples does not work

Wed Jan 03, 2018 2:20 pm

Hi,
I tried this example on pi 2 model B: https://github.com/dwelch67/raspberrypi ... ter/uart04
I adjust it to pi2 (the original is pi 1) my code: https://github.com/kamomil/raspberrypi/ ... 4/uart04.c

but it does't work, it seems to reset all the time , as once it suppose to reach: https://github.com/kamomil/raspberrypi/ ... t04.c#L211

It prints the strings from the beginning of the main function (notmain)

dwelch67
Posts: 938
Joined: Sat May 26, 2012 5:32 pm

Re: uart04 in bare metal examples does not work

Thu Jan 04, 2018 1:52 am

Need to change that readme as well, those top level examples are for the original pi. Try the boards directory and see the options as how you startup and run the chip determines how events/interrupts work. gets worse for the pi3. and sadly if this pi2 you have uses the pi3 chip not the old pi2 chip then look at the pi3 stuff.

dwelch67
Posts: 938
Joined: Sat May 26, 2012 5:32 pm

Re: uart04 in bare metal examples does not work

Thu Jan 04, 2018 2:01 am

You are in the right place, but first you need to figure out if you have the pi2 with the armv7 or with the armv8. then what mode do you want 32 or 64 bit (if the armv8), HYP, SVC, etc...Then from there you can determine how exceptions work. The folks here are very well versed. I have a selection of examples to try to cover the combinations but perhaps dont have every combination. But it should get you started or started down the right documentation or question path.

DOH! I thought you were saying blinker04. uart04 in the top level directory is pi1 only look at the addresses:

#define GPFSEL1 0x20200004
#define GPSET0 0x2020001C
#define GPCLR0 0x20200028

the pi2 and pi3 are 0x3Fxxxxxx not 0x20xxxxxx.

eww actually uart04 has interrupts, so it is a double problem. should work mostly on a pi-zero but go back to what I was saying above about architecture and modes and how you boot, etc. that leads you into the how to deal with events/interrupts. then of course the addresses for the pi2 and pi3 are 0x3Fxxxxxx based wherever you see 0x20xxxxxx and the led if any (on a gpio) are on some other pin.

dwelch67
Posts: 938
Joined: Sat May 26, 2012 5:32 pm

Re: uart04 in bare metal examples does not work

Thu Jan 04, 2018 2:03 am

you are in the right place as in the folks here are very knowledgeable about events/interrupts on the various chips/cores. look at the options pick one path (for example the without config.txt path) see if you can get that to work, then get a little more complicated as needed/desired.

dafna
Posts: 9
Joined: Wed Dec 20, 2017 6:55 pm

Re: uart04 in bare metal examples does not work

Thu Jan 04, 2018 8:26 am

Hi,
Thanks,
I did change the code to fit the addresses to the pi2:
https://github.com/kamomil/raspberrypi/ ... 4/uart04.c

dafna
Posts: 9
Joined: Wed Dec 20, 2017 6:55 pm

Re: uart04 in bare metal examples does not work

Thu Jan 04, 2018 9:16 am

I have a filling that the problem is in the context switch code, the code that stores the registers and then restore them:
https://github.com/dwelch67/raspberrypi ... tors.s#L77.
The registers are just pushed to the stack but the sp itself is not stored.

dwelch67
Posts: 938
Joined: Sat May 26, 2012 5:32 pm

Re: uart04 in bare metal examples does not work

Thu Jan 04, 2018 9:31 pm

those are compatible instructions, the return from the isr is probably wanting to be an eret, but see the pi2 examples not the pi1.

Return to “Bare metal, Assembly language”

Who is online

Users browsing this forum: No registered users and 3 guests