sandeepmistry / arduino-BLEPeripheral

An Arduino library for creating custom BLE peripherals with Nordic Semiconductor's nRF8001 or nR51822.
MIT License
464 stars 180 forks source link

NRF51822 16kB ram /128kB flash #235

Closed spriggsy closed 6 years ago

spriggsy commented 6 years ago

Im currently reprogramming a prebuilt beacon using your excellent arduino core. many thanks for your help so far.

The chip that I'm using only has 128Kb of flash. everything loads and works fine using SD110 until I try using Serial.print. It then fails on the upload. heres the output:

Open On-Chip Debugger 0.10.0-dev-00254-g696fc0a (2016-04-10-10:13) Licensed under GNU GPL v2 For bug reports, read http://openocd.org/doc/doxygen/bugs.html debug_level: 0 0x4000 adapter speed: 1000 kHz nrf51.cpu: target state: halted target halted due to debug-request, current mode: Thread xPSR: 0xc1000000 pc: 0x000006d0 msp: 0x000007c0 Programming Started auto erase enabled nrf51.cpu: target state: halted target halted due to breakpoint, current mode: Thread xPSR: 0x61000000 pc: 0x2000001e msp: 0x000007c0 wrote 32768 bytes from file C:\Users\Spriggsy\AppData\Local\Temp\arduino_build_563943/starter.ino.hex in 1.835025s (17.438 KiB/s) Programming Finished Verify Started Error: timed out while waiting for target halted nrf51.cpu: target state: halted target halted due to debug-request, current mode: Handler HardFault xPSR: 0x81000003 pc: 0xfffffffe msp: 0x000007a0 Error: error executing cortex_m crc algorithm Error: checksum mismatch - attempting binary compare diff 0 address 0x00020020. Was 0x00 instead of 0x04 diff 1 address 0x00020021. Was 0x00 instead of 0x20

this then continues to all the way up to:

diff 63 address 0x00020071. Was 0x00 instead of 0x81 diff 64 address 0x00020072. Was 0x00 instead of 0x01 No more differences found. embedded:startup.tcl:454: Error: Verify Failed in procedure 'program' in procedure 'program_error' called at file "embedded:startup.tcl", line 498 at file "embedded:startup.tcl", line 454 the selected serial port at file "embedded:startup.tcl", line 454 does not exist or your board is not connected

I'm hoping that this is an easy fix that i suspect is to do with only having half the needed Flash size?

Any help appreciated Many thanks Spriggsy

spriggsy commented 6 years ago

Update,

Ive changed Boards.txt to include the following two lines

Generic_nRF51822.menu.chip.xxab=16 kB RAM, 128 kB flash (xxab) Generic_nRF51822.menu.chip.xxab.build.chip=xxab

this adds the menu item to select a new option. and tells the compiler to use the new chip. I have changed the linker file(amgcc_s110_nrf51822_xxab.ld) contents to what i believe are the correct memory maps

MEMORY { FLASH (rx) : ORIGIN = 0x18000, LENGTH = 0x8000 RAM (rwx) : ORIGIN = 0x20002000, LENGTH = 0x2000 }

however the errors remain.

Am I on the right path here???

Spriggsy

spriggsy commented 6 years ago

Managed to fix this by changing the boards.txt to include the new board as in the comment above.

the linker file has this map for the memory.

MEMORY { FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x20000 RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x4000 }

I'm now getting serial out working correctly.

Cheers Spriggsy.