PeterLemon / RaspberryPi

Raspberry Pi Bare Metal Assembly Programming
447 stars 67 forks source link

Hello World demo #8

Closed szoshi closed 8 years ago

szoshi commented 8 years ago

Hello Guys,

I am trying out the Hello World demo on a RPi 2. I have an SD card (32 GB Samsung EVO Plus) formatted for FAT32 and I have copied 4 files to this card as suggested. bootcode.bin start.elf kernel7.img (This image has been downloaded directly and not built locally) config.txt

The screen shows just a rainbow pattern which it seems means that the Pi cannot load the kernel.

Am I doing something wrong? Any help would be appreciated.

Regards, Shailesh

szoshi commented 8 years ago

Hello again, formatting the SD card seems to have done the trick. Regards, Shailesh

PeterLemon commented 8 years ago

Hi Shailesh, glad you solved the problem, I was going to suggest formatting the SD card, or trying to use another SD card. I hope you have fun programming the Raspberry Pi 2 =D

szoshi commented 8 years ago

Hello Peter, Sorry about opening this issue but this is just a casual coment since I don't know how else to reach you. Your tutorials are excellent, in fact I have been looking for something like this since months and could somehow not find it till now. One thing worth considering when doing assembly programming is that if one is testing constantly on the Pi then one is likely to destroy the SD card or the reader sooner or later. Have you, for e.g., ever tried your assembly language programs on an emulator like qemu? If yes, a small tutorial for setting up qemu for the purpose would be very helpful. I am requesting this because as of now, I am very new to the Pi (I have done a lot of assembly, mostly for µCs) and I have noticed that assembly with the Pi is not getting the attention that it should be. An emulator tutorial could really accelarate the pace for someone who is programming in assembly for the Pi. What I also plan to do in the future is to write some code in Python and then have it compiled for the Pi and integrate it with some assembly code. A quick testing environment would go a long way. Sorry about the long-ish post and thanks again! Best regards, Shailesh

DawidPi commented 8 years ago

Hi. Although email is directed to the Peter, I think I can tell you, that such an emulation is rather impossible. You are not able to simulate hardware stuff this way. Eg. You will not have proper dma simulation or GPIO, that's why hardware simulation on qemu is rather hard.

Even though I think there are some attempts to emulate raspberry on qemu, but I think you should Google it as I have never had a closer look into that.

In terms of destroying SD card, it's worth using some bootloader, which uses UART for example. Give it a try it's very convenient.

szoshi commented 8 years ago

Hello David, thanks for the clarification. The alternative with the bootloader is a great suggestion. I googled a bit and found rasbootin as an option. I have to try and get the communication utility to build for Windows and then I can test. Are there any other bootloaders that I might have missed? Google has not been my best friend when it comes to looking for information about development for the Pi. Best regards, Shailesh

DawidPi commented 8 years ago

What I am currently using is bootloader from David Welch. He has got quite a big repository concerning raspberryPi here on gitHub: https://github.com/dwelch67/raspberrypi I personally use bootloader07, that accepts hex files.

With a little bit of modification of the source code you are able to make raspberryPi work in finite loop eg. Place bootloader at 0x8000, which is default and make bootloader to jump to 0x10000 (by default it is 0x8000), then you can link your program to 0x10000 and at the end of your program make a jump to 0x8000. In this way at the end of your program, control is given back to bootloader.

By default bootloader sits at 0x8000 and your program overwrites bootloader, so raspberryPi must be powered off and on to be able to upload new program.

I hope this will help you a bit :)

Best regards, David

szoshi commented 8 years ago

Hello David, I am a bit confused now, definitely due to my very limited knowledge about the Pi. I am assuming that the bootloader runs some basic software and waits for commands from the UART. I then send a hex file over UART with hyperterminal and this application is then executed before returning control to the bootloader. Is this correct? The source you mention above is the kernel7.asm that I am using now, right? The code originates there at $0000 though. Can you post some pseudo code? Best regards Shailesh