Showing posts with label EzSBC2. Show all posts
Showing posts with label EzSBC2. Show all posts

Thursday, 30 July 2015

Why your binary will not run on LPC1347 - the missing checksum

So, you've compiled your code and now you have a binary. You've dropped that binary into your LPC1347 / EzSBC2 board, and it won't run. In fact, you get the Mass Storage Controller bootloader popping up.

This is because the bootloader that runs from ROM checks to see if a valid user program is present in flash.

The way it does it is as follows (from LPC1315/16/17/45/46/47 User manual):

21.7 Criterion for Valid User Code
The reserved ARM Cortex-M3 exception vector location 7 (offset 0x0000 001C in the vector table) should contain the 2’s complement of the check-sum of table entries 0 through 6. This causes the checksum of the first 8 table entries to be 0. The bootloader code checksums the first 8 locations in sector 0 of the flash. If the result is 0, then execution control is transferred to the user code
If the aforementioned checksum is not valid, your code won't run. When you compile in EmBlocks, it does not put in that checksum.

An easy fix to the problem is a command line tool called LPCRC that will calculate and correct the checksum in your binary. I found it in the tools/ section of the Microbuilder LPC11U/LPC13U Code Base, which is an excellent resource for programming your LPC1347.

Wednesday, 22 July 2015

Debugging in EmBlocks part 1: LPC1347 core speed and .SVD files

I now have my Jlink up and running and debugging the EzSBC2 in EmBlocks. Since I am a bit suspicious how the mbed library handles things, I wanted to check the core clock speed from the debugger.

Checking the core speed from System Registers


However, when I tried to look at the System Registers debug window to verify that my LPC1347 is indeed running at the correct MHz, the window was empty.

What we need is a so-called device description file (.SVD) that describes the internal registers of the MCU to the debugger.

You can get the .SVD for LPC1347 from NXP lpcware site here. 

Stick the .svd file path into your Debug->Interfaces settings thus:


After I had put in the .svd and restarted the debugger, I finally got the info I needed:

NOTE: you will see register values only when the debugger is halted !! NOT when the MCU is running.

SYSPLLCTRL says MSEL is 5. Therefore main clock is (MSEL+1)*oscillator (12 MHz) = 72 Mhz.
SYSAHBCLKDIV says DIV is 1, therefore core clock is main / 1.

= System Core Clock is 72 MHz, as intended.

Monday, 20 July 2015

Importing your mbed project to EmBlocks

Unpack the .zip file you got by exporting from mbed online compiler (see previous post).

Open up EmBlocks (or EmIDE, depending on what version you are using).

Import the .eix (EmBlocks eXport) file to EmBlocks:




Put in correct settings for your debugger:


And your device settings (under the Settings >> button)



Exporting your mbed project for EzSBC2 to EmBlocks (EmIDE)

Ok. So the first thing to be aware is:

There is a bug in mbed export for DipCortex M3 & EmBlocks

What I mean by this is that if you export the official mbed lib from mbed online compiler, you will get a zip package with .h headers ... but the actual lib is missing ! So you will not be able to compile in EmBlocks (new version known as EmIDE). You need to import mbed-src to your program, and then export it.

After mbed-src is added to your project, and you have tested it builds in your mbed online compiler, you are ready to export, thus:





Blinking EzSBC2 LED's in mbed online compiler

User Jim Kizos has written the basic blinky for EzSBC2 in the mbed environment.

main.cpp is like thus:

#include "mbed.h"

// EzSBC2 has 2 LEDs P1_15 and P1_16

DigitalOut Led1(P1_15);

DigitalOut Led2(P1_16);

int main()
{
    while(1)
    {
        Led2 = !Led2;
        wait_ms(250);
        Led1 = !Led1;
        wait_ms(250);
    }
    }


 Tricky bit 1:

There is no target "EzSBC2" in the mbed online compiler. We need to target DipCortex-M3. You can use all the mbed examples for DipCortex M3, provided you change the pinout to suit the EzSBC2 !

 Tricky bit 2:

Remove the precompiled mbed library. Import the mbed-src full source library into your program. This is because there is a bug in the export to offline IDE / EmBlocks script - the library is not included in the package if you export the official pre-built mbed library - i.e. you won't be able to build in EmBlocks with the package you'll get !! When you export the program with the mbed-src, you'll get everything and will be able to build in EmBlocks (the next blog entry will be about this).


Thursday, 25 June 2015

Connecting JTAG debugger to EzSBC2

I have one of these:


... and I plan to use it with Keil MDK and the EzSBC2. The EzSBC2 has SWD (single wire debug) interface, so I need to figure out the connection between the 20-pin JTAG and the EzSBC.

Keil has information on their page about connectors. This info is from there.

I also combined the EzSBC2 schematic and a picture of the board.

UPDATE: Checked and works fine. Pull-up / pull-down resistors were not needed. SWO pin is optional.


Wednesday, 24 June 2015

The EzSBC2 dev board by EzSBC

http://www.ezsbc.com/index.php/
After searching for "LPC1347" on ebay, I settled on buying a EzSBC2 board from EzSBC in USA. I did not want to buy the more known/popular LPCXpresso, because there is just something that I don't like about them. The detachable debugging interface and ... blech. Small and simple is better. And cheap.

The EzSBC2 arrived very quickly (a week ?) from ordering and cost me only 18 €. It arrived in a very well packed box, with some quality pin headers. The EzSBC2 is very similar to the DipCortex M3 and apparently, someone else has been using it with mbed also.

Before I bought the EzSBC2 I checked out what kind of forums the manufacturer had. As it turns out, EzSBC company founder (?) Daniel is very helpful and active on the forumThat sealed the deal for me, right away. With new devices, you want to have all the information you can. It can really speed your progress.

EzSBC2 - ARM Cortex M3 - LPC1347 - 64kB Flash, 12 kB SRAM

 Next update will be about actually programming the EzSBC2 using the mbed online compiler