TheYongGrand
Posts: 3
Joined: Sun Jan 25, 2015 1:20 am

Bare metal programming - downloading programs

Sun Jan 25, 2015 1:31 am

Hey there,

I just read about the Raspberry Pi Bare Metal programming and it seemed that everytime I compile the kernel.img file, I have to copy the image file into the SD-Card, and insert into the Pi, and then do it again if I have to modify the program. That would have ruined the SD-Card slot if I do it too many times.

Are there alternatives of doing all these? Like copying or auto-loading the firmware into the system like any other microcontroller? I read about the JTAG debugger in the net but the tutorials are very sparse.

ShiftPlusOne
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 6037
Joined: Fri Jul 29, 2011 5:36 pm
Location: The unfashionable end of the western spiral arm of the Galaxy

Re: Bare metal programming - downloading programs

Sun Jan 25, 2015 3:04 am

I used raspbootin https://github.com/mrvn/raspbootin
u-boot should work as well.

User avatar
rpdom
Posts: 15411
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Bare metal programming - downloading programs

Sun Jan 25, 2015 8:01 am

I haven't had any problems with the SD card slot from repeat insertion/removal of the SD cards during bare metal testing or any other work.
The only things I had fail are cheap SD cards or micro SD adaptors that have split at the corners. I'm quite happy to throw those away and get replacements on the rare occasions they are needed. I'm actually using some old MMC cards now that seem to be more solidly built than SD cards.

clarkpadgett
Posts: 16
Joined: Sun May 19, 2013 11:19 am

Re: Bare metal programming - downloading programs

Sun Jan 25, 2015 12:32 pm

I used Transcends Wifi SD card. I found information about hacking it and was able to turn it into an FTP server

User avatar
DexOS
Posts: 876
Joined: Wed May 16, 2012 6:32 pm
Contact: Website

Re: Bare metal programming - downloading programs

Sun Jan 25, 2015 3:56 pm

Batteries not included, Some assembly required.

TheYongGrand
Posts: 3
Joined: Sun Jan 25, 2015 1:20 am

Re: Bare metal programming - downloading programs

Mon Jan 26, 2015 12:56 am

Thanks for the help guys.

I have the Raspberry Pi Model A+, and the problem is taking out the SD card in and out too many times would just break the slot really fast.

The older Raspberry Pi Model B has an older SD-card which I can use a converter (micro SD to SD). At the least the converter breaks before the slot does. :)

Anyway, is there a compiler which I can fully automate the compiling process for the bare metal examples? Or else if not, I would have to use a batch file by myself.

tufty
Posts: 1456
Joined: Sun Sep 11, 2011 2:32 pm

Re: Bare metal programming - downloading programs

Mon Jan 26, 2015 8:29 am

Most SD card slots (and SD cards, come to that) are rated for an average 10,000+ insertions before failure. That's 3 years of 10 insertions a day.

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

Re: Bare metal programming - downloading programs

Mon Jan 26, 2015 2:45 pm

interestingly I have broken several micro sd to sd card adapters in the early raspberry pis, the problem only stopped when the adafruit adapter came out (and the switch to micro sd slots instead of full sd hanging in the wind). Have never had problems other than a raspberry pi...

User avatar
led-bloon
Posts: 11
Joined: Mon Dec 03, 2012 4:48 am
Location: Oz

Re: Bare metal programming - downloading programs

Mon Jan 26, 2015 8:16 pm

I have set up a system, mainly using Dave Welch's code - modified.
Currently I'm using it "pi2pi" where I use my mini-terminal program
plus his downloader program to download, test and reboot WITHOUT
pulling the SD card or powering on/off the bare metal pi.
Some examples including gpio, spi with piFace are included.
There's a ReadMe.txt explaining more.
I have made the code available from my google drive, here:
https://drive.google.com/file/d/0B2mcl3 ... sp=sharing
Hope this is of use to someone...

hldswrth
Posts: 108
Joined: Mon Sep 10, 2012 4:14 pm

Re: Bare metal programming - downloading programs

Tue Jan 27, 2015 9:33 am

For cross-platform development I would recommend using Eclipse and Yagarto on your build computer.

I use a USB to 3.3v serial adapter I got from ebay and a USB extension lead to connect the Pi to the PC. My hobby OS includes a serial port driver and SD card writer so I can download an updated O/S that way. An alternative approach others have taken is to have your kernel.img be a small program which makes a serial connection and pulls down the rest of the kernel via that connection every boot.

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

Re: Bare metal programming - downloading programs

Tue Jan 27, 2015 6:28 pm

jtag makes things quite nice as well, my repo talks about it. The ftdi 2232 and 4232 mini modules are well under $50 solution, but you do need a number of jumper wires and no mistakes, so the pucker factor for folks a little worried about making a mistake goes up. Bare metal in general you risk smoking the hardware so you have to find a way to get comfortable. the jtag approach you get multiple/many tries at things before you have to power cycle or reset. I find myself not bothering with the number of connections and using the serial bootloader. It helps that it is easy to add a reset button and you dont have to find a way to yank power.

Not sure if it has been figured out yet, and I probably dont have the energy to do this but the gpu jtag is there and if we were to learn enough about that interface we could go in and reset the arm (Assuming the gpu has the ability not only to start the arm but also reset it) load it with whatever software, etc and not have to do the arm thing where a small bootloader is needed to change to alternate functions for the gpios to get jtag into the arm. Hmmm....

I gave up on a network/wifi approach, kept losing interest. Taking over the sd card interface is a nice solution.

David

TheYongGrand
Posts: 3
Joined: Sun Jan 25, 2015 1:20 am

Re: Bare metal programming - downloading programs

Sat Feb 07, 2015 3:25 pm

Hey there,

Just tried messing with the bootloader, but with some problems: (I rather to see a problem first than to have them later!)

Here's what I did earlier:

1.) Created a SD card with Linux from R-pi tutorial.

2.) Accessing the boot partition - replaced the "kernel.img" with the "kernel.img" from dwelch67's webpage (bootloader05).

3.) Connected the serial port to the R-pi (checked the GPIOs), using a Prop-plug (Parallax Inc. - they used the same USB->Serial converter) They are 3.3V compatible, so there wouldn't be any cooking occuring there.

4.) Used a Realterm because I do not have a Linux to do the "minicom" thing. I dumped the "blinker.bin" and unfortunately I didn't see anything. Should there be a feedback from the R-Pi to the terminal saying that "R-pi Bootloader is connected"?

5.) From the dwelch67's tutorial on the newer B+, where's the GPIO47? I think the problem in (4) is because the particular GPIO is sharing with the RX pin. (I have the Raspberry Pi A+).

I'll keep reading for more info - most of the tools are geared towards Linux and since I'm a long time Windows user, I have to do it real slow. :D

krishnaiah.vv
Posts: 19
Joined: Wed Jun 24, 2015 7:34 am

Re: Bare metal programming - downloading programs

Wed Aug 26, 2015 6:30 am

led-bloon wrote:I have set up a system, mainly using Dave Welch's code - modified.
Currently I'm using it "pi2pi" where I use my mini-terminal program
plus his downloader program to download, test and reboot WITHOUT
pulling the SD card or powering on/off the bare metal pi.
Some examples including gpio, spi with piFace are included.
There's a ReadMe.txt explaining more.
I have made the code available from my google drive, here:
https://drive.google.com/file/d/0B2mcl3 ... sp=sharing
Hope this is of use to someone...
Hey, the access to your files is restricted. Can you pls do a public share or share me([email protected])?
Is spi slave implementation available in this folder?

Return to “Bare metal, Assembly language”