All right so, another thing as mentioned before, we've got another default kind of situation, when it comes to the C library. So, if you are using any C library functions maybe printf() or something like that and I/O function maybe, there's some other things, that you might be using like some error handling functions. A lot of these functions require something called semihosting, the thing I mentioned earlier, and semihosting is something that is a bit quirky. That means a little bit odd, it's not so easy to figure out how it works if you haven't come across it before, but essentially what it boils down to is that the functions themselves at a lower-level. And there there will be some calls to functions like this one _sys_write()
14
00:01:18,752 --> 00:01:23,302
for example or
fputc(), and iff maybe you're using printf() one of those functions will get called eventually. So those functions might contain a special instruction, a breakpoint instruction, with a magic number that follows it. And for Cortex-M processes that number is 0xAB, So, what does that mean? Why would you have a breakpoint instruction, in your program? Well, normally breakpoint instructions would trigger a breakpoint and caused the processor to enter Debug state. So normally if you wanted to maybe debug your system, you would set a breakpoint. Maybe if you're using an IDE, and you've got a debugger attached to the system, you could set a breakpoint in that IDE and then maybe run to that line of code and check what's happening, and that's the typical usage of breakpoints, to stop when an instruction is about to execute. But if the debugger encounters a breakpoint instruction with an 0xAB that follows it, and it supports semihosting, it might be able to handle a specific task, such as maybe printing a character out to an I/O screen. Or maybe doing some kind of error handling or setting up the stack and the heap, or something else for you. Because at an early stage of software development, you might not have retargeted printf() to a real I/O device, like a UART a serial interface. So, there's this kind of magic semihosting support that's added by default. You don't want this when you move away from your development environment to the real-world standalone application. So we'll look at how to avoid this semihosting functionality and how to re-implement the default C library behavior. And also look at how to maybe even avoid the C library if you don't want to use it, or maybe you've got a requirement to use a different C library. So there are lots of different use cases, and we will basically try to cover as much of those as possible, and explain semihosting in a little bit more detail. By default you get some from libraries, with Arm Compiler 6, some of them are shown here, so there is a C library here, there are little and big-endian versions of libraries. This one's a helper library and the 'f' here stands for floating-point, so this is a floating-point library. And the 'w' I think here is that an old project name for Thumb used to be known as wrist when it was being developed, a little secret for you that I've slipped out there, and that's still found in our library naming convention. So if you ever working with the library from a company that develops a compiler, and and library tools to to go with that, you'll probably need to figure out which libraries are appropriate to use as well and whether those libraries support the semihosting instructions shown here as well, the BKPT 0xAB instruction. Just a minor point here, it's not really related to booting and initialization, but there is a microlib library which is very good for code size. So maybe if you do have a limited amount of memory, in your system, you might want to link in the micro library, I think in GCC it's called the nanolib and that might save you a bit of code size. There are some restrictions with those libraries don't comply to every standard and, aren't necessarily going to work for everyone, but they work for lots of people, and can really save a bit in terms of the memory footprint that the application would require.