Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

PIC32MZ Bootloader in Assembly

Status
Not open for further replies.

chipmonk1027

Newbie level 6
Joined
Oct 24, 2012
Messages
12
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,397
Hi Guys,

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.

Thanks for taking a look.
 

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?
 

I have read that the microchip C32 compiler allows you to do this
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
static unsigned int _excep_code;
static unsigned int _excep_addr;
 
// this function overrides the normal _weak_ generic handler
void _general_exception_handler(void)
{
    unsigned int 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));
}

 

I have read that the microchip C32 compiler allows you to do this but I have not tried this. Any comments?

A few suggestions:

Start with inline assembly codes: they are the easiest to start. Next,

Write a small C program - get the assembler listing and use that as the starting point for a full assembler program.

The trick is not to try too much at one go; divide and conquer!

I personally found (that was good old days) that debugging an asm program is a real nightmare. Naturally I did not progress far.

Happy assembling!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top