I would like to develop a booloader for my PIC32MZ2048 in assembly. I am adapt to MPSAM, I would like to know which enviroment I should use to write the assembly code. I would also appreciate any working code (blinky...etc) just to get me going.
I have taken a brief look at the harmony bootloaders, but I still feel the need to develop one in assembly.
Microchip (and I would imagine many others) have bootloaders already for the PIC32 range of devices.
What is wrong with these that make you want to write your own?
What is the goal you have that makes you think a bootloader is part of the solution? (https://xyproblem.info/)
Also there are many code examples out there to flash a LED. However if you think you need code at this level - presumably because you are starting off with this family of devices - then it is a *very* large leap to writing a bootloader.
Susan
I am also interested in writing assembler for the pic32 chips, I have read that the microchip C32 compiler allows you to do this but I have not tried this. Any comments?
Sure. You can write inline assembler code in C sources or write pure assembly sources. Refer to the GNU C and C32/XC32 manuals about details.
If you are writing complex PIC32 code, you'll get in touch with MIPS assembly language sooner or later. Either when debugging code at the assembly level or achieving specific low level tasks.
Writing assembly code as en end in itself seems just useless to me.
- - - Updated - - -
Here's a small example of inline PIC32 assembly code ("achieving specific low level tasks"). Come back when you managed to understand its operation.
Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
staticunsignedint _excep_code;staticunsignedint _excep_addr;// this function overrides the normal _weak_ generic handlervoid _general_exception_handler(void){unsignedint mod_addr;
asm volatile("mfc0 %0,$13":"=r"(_excep_code));
asm volatile("mfc0 %0,$14":"=r"(_excep_addr));
_excep_code =(_excep_code &0x0000007C)>>2;// Skip instruction causing the exception
mod_addr = _excep_addr +4;
asm volatile("mtc0 %0,$14"::"r"(mod_addr));}