bootloader

stm32实现iap远程固件更新

自古美人都是妖i 提交于 2019-12-29 11:25:51
前提 想来做iap升级了,应该不是什么新手。 下面的程序需要用到一些简单的功能 串口收发数据 开关总中断 虽然本文标题是实现远程固件更新,但是具体远程方案本文不做详细说明,重点在于介绍mcu接收到新的固件后怎么保存更新,以及更新失败回滚等。下面简单说明一下远程的事情。 stm32的通信方式有串口,spi,iic,以及sdio等。也就是说我们的固件可以通过这些方式传输到mcu,不过普遍常用的是串口或者用sdio(外接sd卡)这两种方式。个人觉得用sd卡来回copy也不怎么方便。简单点还是再加一个串口网络模块,然后把固件存到服务器,经由串口网络模块透传到mcu。比如用http协议把固件发送下来。远程下载就这么简单一说。接下来重点分析更新的事情。 固件生成 远程更新使用的固件和我们平时烧录程序用的固件格式有点区别,我们需要用二进制格式(.bin)文件。生成方式以mdk为例介绍一下,只需要添加一条命令行。 在mdk工程配置选项选择User,这个页面是让我们添加自定义命令行的,我们要添加的命令添加到第三个选项,即在编译完成后执行。下面是命令内容,需要注意的是 bin前面两个-,app1.bin就是生成的固件,名字可以自定义,**.axf是你工程实际的.axf文件,路径要正确。不知道你的axf在那在output页面查看。 fromelf.exe --bin -o ../app1.bin ./*

How to reduce the code space for a hexadecimal ASCII chars conversion using a _small_ code space?

送分小仙女□ 提交于 2019-12-29 01:38:13
问题 How to reduce the code space for a hexadecimal ASCII chars conversion using a small code space? In an embedded application, I have extraordinary limited space (note 1). I need to convert bytes, from serial I/O, with the ASCII values '0' to '9' and 'A' to 'F' to the usual hexadecimal values 0 to 15. Also, all the other 240 combinations, including 'a' to 'f', need to be detected (as an error). Library functions such as scanf(), atoi(), strtol() are far too large to use. Speed is not an issue.

How do I write a bin file (512 bytes) to the first sector (sector 0) of a floppy disk?

白昼怎懂夜的黑 提交于 2019-12-28 04:04:37
问题 How do I write a .bin file to be in the first sector of a floppy disk/virtual floppy disk/floppy image? I'm trying to boot a simple 512-byte bootloader. The size on everywhere says "512 bytes" so I should be good already. Additional Information: The bootloader simply displays a string, and I'm learning simple assembly. Some of the work is made in Windows and some in Ubuntu 14.04 (Trusty Tahr) (if this matters). It doesn't boot even though it has the bootloader sign. 回答1: If you are on Linux

NASM module to convert hex into string and print it out. Assembles but not working as expected

蹲街弑〆低调 提交于 2019-12-25 18:26:49
问题 I am trying to write a simple assembly code to spit out hex values to the screen. There are two files print_screen.asm which is working with other modules. I think the problem is in my logic when trying to convert hex to string. My code is: [org 0x7c00] xor dx,dx xor ax,ax xor bx,bx mov dx, 0x1fb6 call print_hex jmp endi; print_hex: pusha mov ax,0x0001 and ax,dx add ah,48 mov byte [HEX_OUT+5],ah mov ax,0x0010 and ax,dx add ah,48 mov byte [HEX_OUT + 4],ah mov ax,0x0100 and ax,dx add ah,48 mov

GDB step over command

天大地大妈咪最大 提交于 2019-12-25 06:55:18
问题 I have the following C code: #include <inc/x86.h> #include <inc/elf.h> #define SECTSIZE 512 #define ELFHDR ((struct Elf *)0x10000) // scratch space void readsect(void*, unit32_t); void readsec(uint32_t, uint32_t, uint32_t); void bootmain(void) { struct Proghdr *ph, *eph; // read 1st page off disk readseg((uint32_t) ELFHDR, SECTSIZE*8, 0); . . // REST OF CODE . } I am using gdb to step in my code and see what is happening. I found the address of bootmain 0x7d0a and I put a breakpoint there. b

How to compile a simple multiboot2 bare-metal executable?

安稳与你 提交于 2019-12-25 04:07:34
问题 I want to start to write an os kernel, and then, i found a document introducing multboot2 spec. There are three example code files, named boot.S , kernel.c and multiboot2.h , belonging to the multiboot2 branch of grub project. Firstly, i tried to compile and link the code with some option (using i686-elf-gcc) such as -nostartfiles , -nodefaultlibs and -ffreestanding , but qemu showed me the format was error. And then i found a file named Makefile.am , and the compiler option in this file is

Bootloader for Cortex M4 - Jump to loaded Application

跟風遠走 提交于 2019-12-24 16:37:32
问题 I am using a Atmel SAM4E-16e on Atmel SAM4E-EK Board. I have written a bootloader for this configuration. The bootloader receives the .bin-File via UART and writes it into Flash. This works without problems, i made a hex-dump and it was exactly what i expected: Bootloader at 0x400000 (Flash Start Address of AT SAM4E) My Application at 0x420000 0x800000 is Flash End Address This is the C-Code: int main(void){ // Init and downloading the .bin to Flash binary_exc((void*) 0x420000); } int binary

Filesystem on Loop Device not Recognized by Linux when Bootloader is Written to it

与世无争的帅哥 提交于 2019-12-24 12:44:18
问题 I am currently writing a bootloader in x86 NASM assembly designed to load a kernel (R.BIN) from a FAT16 filesystem and jump to it. I have been writing the bootloader to a blank image that I have mounted by using sudo losetup loop21 image.img . I would write the image using sudo dd if=LOADER.BIN of=/dev/loop21 . Of course, the bootloader didn't work immediately (I was basing it off of a FAT12 bootloader and forgot to change a few things). After making dozens of edits, at some point, Linux

error: unrecognised directive [ORG]

人盡茶涼 提交于 2019-12-24 10:57:26
问题 I was trying to write a boot-loader to use in dos-box I wrote the following code [BITS 16] ;tell the assembler that its a 16 bit code [ORG 0x7C00] ;Origin, tell the assembler that where the code will ;be in memory after it is been loaded JMP $ ;infinite loop TIMES 510 - ($ - $$) db 0 ;fill the rest of sector with 0 DW 0xAA55 ; add boot signature at the end of bootloader I was trying to assemble it using nasm by the following command nasm -f elf myfile.asm Then I see that error error:

Is the load address at compile time the place to copy the executable in RAM?

ⅰ亾dé卋堺 提交于 2019-12-24 08:15:13
问题 I am trying to write my own loader. In this program, I will copy the program to the specific address in RAM, and will jump on to the entry point address by reading the entry point of elf. But, I am not able to understand what is the loader address? Does it mean that the binary needs to be copied only at the loader address specified at compile time. can't I load the program in some other location rather than the load address specified during compile time? My basic question is the following,