0

I would like to have some kind of mechanism to somehow load the RAM on the Raspberry Pi programmatically from a controller computer (I assume through the SD interface) and then let the Raspberry Pi's CPU execute. Is there some kind of device that does this? And what is it programmed in?

It would also be great if there's a way to interrupt the whole thing from the controlling computer if needed.

Charles
  • 50,943
  • 13
  • 104
  • 142
Stephane Grenier
  • 15,527
  • 38
  • 117
  • 192

1 Answers1

1

SD is a fairly poor choice for an interface to try to push data into from an external source; generally the computer hosting the SD device wants to be the master of operations.

But the Raspberry pi has both uart serial ports and (on the model B) an ethernet interface. Downloading code through either is quite normal.

You haven't mentioned if you want to run an application atop a typical linux installation, or if you want to do bare metal programming. In the first case you would typically transfer the program to the file system (either ramdisk or the SD card) and then execute it.

In the second case, you would need a stub of code already on the device (which is to say, the boot partition of an sdcard) which knows how to configure peripherals sufficiently to enable reception of code via serial or ethernet (the latter complicated by needing a USB host stack), and then jump into it.

Chris Stratton
  • 39,853
  • 6
  • 84
  • 117
  • bare metal programming, which means the SD card code could be compromised. And from what I understand, it will only boot from the SD card. I agree it would be great to stub the code on the SD card and have it load the the rest of the code through ethernet. In fact that would be more than ideal. The problem is that the code on the SD card on the Rasberry Pi could be overwritten. – Stephane Grenier Oct 16 '12 at 01:42
  • 1
    Technically, yes, it could, though it's unlikely to happen by accident if you deconfigure the SD card interface before jumping into your code. It's extremely likely that the SOC has various slave boot modes, but you would need to talk Broadcom into sharing the specifications, and the necessary pins to strap may not be accessible on the finished board. – Chris Stratton Oct 16 '12 at 01:46
  • So if I understand correctly, you load your very minimal custom boot code through the SD card (your own very basic OS if you will), do some kind of call to the device to lock out any attempts at altering the contents of the SD card, and then load it through the ethernet interface or whatever. And it would only be reset on power up/down. And if I'm right you would also need to protect the memory (RAM) that has your boot code from being altered as well. – Stephane Grenier Oct 16 '12 at 02:02
  • 1
    Not exactly. Talking to the SD card isn't trivial, and takes a bit of setup, which you can probably figure out how to undo again. That makes it unlikely that the SD card will get written to, unless someone purposeful enough to bring along their own interface routines specifically attempts to do so. I don't see why you would need to try to protect the in-ram copy of the boot code; if anything you might intentionally erase it. You'll just get a new copy on the next reboot, unless the SD actually has been changed. – Chris Stratton Oct 16 '12 at 02:24
  • I'm not quite ready to share publicly what I'm working on, but if you can contact me through my blog (listed in my profile), I'd love to share some more details with you to get your opinion because I'm very impressed with your knowledge. I would reach out to you but your profile has no way of contacting you directly. I will admit device programming is a bit out of my norm and I haven't done it in a very very long time, but the end goal is larger than just one device... – Stephane Grenier Oct 16 '12 at 02:39
  • the normal load process of the raspberry pi copies your kernel.img to ram in the arms address space. you can easily make a boot loader and use one of the other interfaces, I have jtag and serial bootloader examples http://github.com/dwelch67/raspberrypi. look around in the bare metal forums and find chad's usb drivers and from that you might use usb in some form or usb to ethernet, etc. – old_timer Feb 05 '13 at 18:35