We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hello,
Does anybody know if I can use the Keil MDK to write baremetal code for the Raspberry Pi?
Thanks.
The keil MDK-ARM kit is designed for smaller microcontrollers.
Any reason you don't want to use the free gcc toolchain for the RP? What advantages do you see with trying to use MDK-ARM? The Keil tools requiers a commercial license, since it isn't meaningful to use the demo version on a RP because of the restrictions in code size.
Hi,
I only want to write small baremetal applications so the Lite version would be great. I want to learn about other development environments.
But the lite edition is still a commercial license that costs money. Just a bit less money than the larger license options.
The completely "free" demo version has extremely limited code size so it is probably not meaningful to use - it is only intended to test the tool and get an idea what the tool can do.
In your case, you will already be able to find complete configuration files for how to build binaries for use on the Raspberry Pi. Running a "bare metal" application on the platform is very similar to compiling the Linux kernel. Your code would be started in the same way that the Linux kernel gets started. Which also means that you can look at the Linux kernel source to see what they do to activate different hardware functions of the processor.
Sorry sir, but I think you are wrong. The Lite version is the same as the demo version. I know it is limited but it is also free. I can make an application up to 32K which I think is plenty for a small baremetal application. Also a baremetal application is not like the Linux kernel. It is more like a bootloader. I want to learn about bootloaders and I want to talk to the chip directly.
I think that the debugger and stuff will not be able to simulate the Broadcom chip, but I want to make simple assembly and C applications and try them. I think that the Keil MDK can produce code to work with the Broadcom core.
The Linux kernel can be run "raw" or you can have a boot loader that starts it. It's just that it is normally easier to have a boot loader start the kernel since a boot loader represents a much easier solution to switch to another Linux kernel version.
You can even find variants where people have thrown out the BIOS from a PC and booting Linux directly from the BIOS flash memory.
Sir,
Sorry but I do not understand why you keep talking about using the kernel and the PC. I know what the kernel does but I do not want to do that at the moment. I want to do baremetal with my Raspberry Pi. To talk directly to the hardware with only a little code. I have found a lot of example code using GCC but I want to learn about using another development environment.
Not sure why Per would want to stop you from experimenting.
Keil isn't particularly well situated for the Raspberry Pi development work, it doesn't seem to have native support for Broadcom CPUs, good hardware/register level documentation for Broadcom or Marvell parts is not at all easy to obtain.
Do you have good JTAG/SWD connectivity to permit low level development?
Most available example source for the platform is likely to target GNU/GCC tools.
"keep talking about using the kernel and the PC" would mean I have said it multiple times. I have said it only once, as an example that the Linux kernel can be used without a boot loader.
I have never said you should use any kernel.
I did write "Your code would be started in the same way that the Linux kernel gets started. Which also means that you can look at the Linux kernel source to see what they do to activate different hardware functions of the processor."
See the difference?
And I said that when using the gcc toolchain, you can already find lots of information how to set it up to build an application for use without any boot loader.
"Not sure why Per would want to stop you from experimenting."
There isn't one single sentence in my posts where I want to stop him from experimenting. All I am questioning is his interest in using the Keil tools, instead of gcc. Do _you_ see any obvious advantage to use the Keil tools instead of gcc?
Do _you_ see any difference in me noting more samples to look at if using gcc, compared to your own suggestion that there are more samples to look at if selecting gcc?
I find that Keil, and Realview before it, had some pretty good debuggers, and I've definitely blind debugged in to hardware for which source wasn't immediately available or I had used GNU/GCC to create. I've stepped through ROMs, boot loaders, and into Linux kernels.
Many systems have staged boot processes, where a simple boot loader pulls in uBoot, bitbox, or RedBoot, which in turn brings in the kernel.
I think Keil is unsuitable for uBoot or Kernel work, but plenty adequate for boot roms or boot loaders, and in many cases 32 KB would be more that enough to do quite a bit of damage. Admittedly you're not going to fill up NAND/DDR with code, but you could log data there, and copy it to an SDCard.
I don't think Keil is a good match for the Pi, I'd probably look for something that had ready JTAG support, and open documentation. John is working with what he has, and is showing a whole bunch more wherewithal than a slew of other posters, and we should be using a tone that's commensurate with the effort to try something new in a constructive fashion.
Sorry for my late reply but my mum told me to go to bed last night.
You said "I have said it only once". But you used the word kernel in two posts before. I told you I want to do baremetal. I did not say kernel because I do not want to do kernel at the moment. Maybe you do not really know what baremetal is.
You said "Your code would be started in the same way that the Linux kernel gets started."
But I already know that! I know all code starts at the beginning.
What I want to do with baremetal is keep it as simple as possible. I do not want to use the code that is in the kernel. I want to learn how to write it myself. I want to learn about something different. I want to get more experience of alternatives.
The kernel is big and is more complicated. I want to keep it simple. I have a Raspberry Pi. I do not have enough money to buy another development board.
I think I asked a simple question about baremetal. I want to learn about different development environments. Please understand. Why do you have to give your opinion about whether it is a good idea? I am learning in my free time. What I do doesn't cost you anything.
Thank you John Linq for starting to answer my question. Can anyone tell me more about what I asked?
-> Can anyone tell me more about what I asked?
Do you have a plan about how to program the Broadcom BCM2835 SoC? Do you plan to store your software on the SD Card, just like NOOBS installer and Raspbian? Do you have a plan about how to debug your software?
Both Per Westermark and Westonsupermare Pier have quite a lot of experiences on Embedded system development, tell us more, so that people can help you better.
Yes, I have used the word "kernel" in several posts. But only one post noting kernel+PC.
And in none of the posts have I said you should use a Linux kernel. I just noted that the Linux kernel can be used bare metal, which means it could be interesting to take a closer look at how that was done - and to take a peek at the kernel code for how to set up some of the hardware your own bare-metal code would also need to configure.
Don't know what bare metal is? Well, how could I not, since I have worked with embedded for a huge many years - including writing boot loaders? In fact, a huge majority of all embedded devices only have bare bone, or requires the developer to both write a boot loader and the actual application just to give the customer a way to field-update the firmware.
"But I already know that! I know all code starts at the beginning."
That is a sentence that just doesn't make sense. All code may have an entry point, and so it would be irrelevant to spend time talking about it unless you have specific issues with that. What I am talking about is the hardware setup that a bare-metal program needs to worry about - like all the oscillator settings, power configurations, memory mappings etc. Not sure if you have thought about it, but lots of low-level information are often not (!) available in a document _you_ can get access to. Which is a reason why it might be meaningful to look at the Linux kernel source to see the data structures, the register values etc.
You say you have little money. In which case gcc have advantages. The Keil tools aren't intended for the processor in the Raspberry Pi.
You may think you asked a simple question. Just don't lock yourself into believing you know what the correct answer is to that question. If you have already decided that the answer is Keil, then there wouldn't have been a need for a question in the first place, would it?
"Why do you have to give your opinion about whether it is a good idea?"
Because that follows directly from your question. You ask if you can use the Keil tools? You might be able to. But they aren't designed for that specific task - the Raspberry Pi processor is not in the list of supported processors. So a good answer then would be to tell you that the Keil tools would most probably not be a good idea to use.