Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUIDE: Building ZiGate firmware #105

Closed
ISO-B opened this issue Dec 20, 2018 · 22 comments
Closed

GUIDE: Building ZiGate firmware #105

ISO-B opened this issue Dec 20, 2018 · 22 comments

Comments

@ISO-B
Copy link
Collaborator

ISO-B commented Dec 20, 2018

Installing SDK and using it to build firmware

Figuring how to install SDK and build ZiGate firmware took me some time. I hope this saves someones time and helps developing ZiGate.

Install BeyondStudio

BeyondStudio is Eclipse IDE for NXP JN51xx C/C++ developers. It is needed to build ZiGate firmware. It is available on NXP website you just need to have account which you can create for free.

  1. Download BeyondStudio for NXP(JN-SW-4141) from HERE
  2. Instal BeyondStudio. I recomend to install it to default installation path, but you can install it anywhere. Install it to other place and you will have to replace some paths later.
  3. Start BeyondStudio and create workspace when asked. Workspace path should be BeyondStudio-installation-path/workspace
  4. Continue to latest released or development version section

ZiGate latest released version

  1. Download JN516x ZigBee 3.0 SDK (JN-SW-4170) for Zigate from HERE
  2. Extract JN-SW-4170 folder from zip to BeyondStudio-installation-path\sdk\
  3. Download ZiGate source code (ZiGate.zip) from HERE
  4. Extract content of ZiGate.zip to BeyondStudio-installation-path\workspace\ZiGate\
  5. Now you should have BeyondStudio-installation-path\workspace\ZiGate\ folder with Build, Doc, JN516x, JN517X, Source, Tools folders and VERSION.txt file
  6. Go to section using BeyondStudio

ZiGate latest development version

  1. Download latest development version from Github. Select desired branch and download it. At time of writing this newest branch is v3.0f. https://github.com/fairecasoimeme/ZiGate/archive/v3.0f.zip
  2. Extract ZiGate-3.0f\Module Radio\Firmware\src\ZiGate\ folder from zip to BeyondStudio-installation-path\workspace\
  3. Now you should have BeyondStudio-installation-path\workspace\ZiGate\ folder with Build, Doc, JN516x, JN517X, Source, Tools folders and VERSION.txt file
  4. Extract ZiGate-3.0f\Module Radio\Firmware\src\sdk\JN-SW-4170\ folder from zip to BeyondStudio-installation-path\sdk\

Evrything would be good but Github breaks code line endings. We need to fix those.

  1. Executables
    1. Download JN516x ZigBee 3.0 SDK (JN-SW-4170) for Zigate from HERE
    2. Extract JN-SW-4170\Tools\ folder from zip to BeyondStudio-installation-path\sdk\JN-SW-4170\ and overwrite all duplicates.
  2. Find and remove all \r characters from .mk, .c, .h files
    1. You can use whatever program you want but I will demonstrace it using Notepad++
    2. Open Notepad++
    3. From menu Search -> Find in files
    4. Fill values
      • Find what: \r
      • Leave Replace with empty
      • filters: *.h
      • Path: BeyondStudio-installation-path\sdk\JN-SW-4170\
      • Search mode: Extended
      • Only checkbox that needs to be checked is "In all sub-folders"
    5. Replace in Files. When asked are you sure double check path and if its correct select yes.
    6. Repeat replacing part with all required file endings.
  3. Library folders
    1. Replace library folders content with working files from JN-SW-4170.zip
    2. At least following folders need to be replaced
      • /Components/Library/
      • /Platform/DK2/Library/
      • /Platform/DK3/Library/
      • /Platform/DK4/Library/
  4. Now everything should be ready for building firmware

Using BeyondStudio

  1. Start BeyondStudio if it is not still running. Select same workspace as earlier
  2. From menu select File -> Import
  3. From Import popup. Under General select Existing Projects into Workspace. Click next.
  4. Select root directory and browse to BeyondStudio-installation-path\workspace\zigate\
  5. Now you should see two projects on projects area. Select JN516x one if you are using ZiGate. Click finish.
  6. Close welcome window
  7. If you installed BeyondStudio anywhere else than default location from Project Explorer select JN-SW-4170. Click it with right mouse button and select properties. Click Edit... button from Location row and find your BeyondStudio installation location from there select sdk and JN-SW-4170. Press Ok. Press Ok.
  8. Click your project "JN-AN-1216-Zigbee-3-0-IoT-ControlBridge" and select Build Configurations -> Set active and select desired build. I have used ZigbeeNodeControlBridge_Coordinator_115200[JN5168] for ZiGate.
  9. Click your project again and select Build Configurations -> Build Selected.
  10. Make sure that desired configuration is selected and also clean and build are checked. Press ok to start building. This will take some time.
  11. If no error other than Memsize.exe appears then you should find your firmware file from folder BeyondStudio-installation-path\workspace\zigate\build\ZigbeeNodeControlBridge\ it is named acording your build configuration and ends with .bin
@pipiche38
Copy link

Very useful contribution!

@ISO-B ISO-B changed the title Building ZiGate firmware GUIDE: Building ZiGate firmware Dec 24, 2018
@pipiche38
Copy link

pipiche38 commented Jan 7, 2019

@ISO-B Thanks very much for this step by step help.

May be you could help me, while
A file : C:\NXP\bstudio_nxp\workspace\ZiGate\Build\ZigbeeNodeControlBridge\ZigbeeNodeControlBridge_JN5169_COORDINATOR_115200.bin /JN-AN-1216-Zigbee-3-0-IoT-ControlBridge/Build/ZigbeeNodeControlBridge/ZigbeeNodeControlBridge_JN5169_FULL_FUN as been generated, I'm however having such error message.

/c/NXP/bstudio_nxp/sdk/Tools/ba-elf-ba2-r36379/bin/ba-elf-objcopy -j .version -j .bir -j .flashheader -j .vsr_table -j .vsr_handlers -j .ro_mac_address -j .ro_ota_header -j .ro_se_customData -j .rodata -j .text -j .data -j .bss -j .heap -j .stack -S -O binary ZigbeeNodeControlBridge_JN5168_FULL_FUNC_DEVICE_115200.elf ZigbeeNodeControlBridge_JN5168_FULL_FUNC_DEVICE_115200.bin
/c/NXP/bstudio_nxp/sdk/JN-SW-4170/Tools/Memsize/memsize.exe /c/NXP/bstudio_nxp/workspace/ZiGate/Build/ZigbeeNodeControlBridge/ZigbeeNodeControlBridge_JN5168_FULL_FUNC_DEVICE_115200.elf /c/NXP/bstudio_nxp/workspace/ZiGate/Build/ZigbeeNodeControlBridge/ZigbeeNodeControlBridge_JN5168_FULL_FUNC_DEVICE_115200_NOLTO.map ZigbeeNodeControlBridge.json
Error loading Python DLL 'C:/Users/pichon/AppData/Local/Temp_MEI6282\python36.dll'.
LoadLibrary: The parameter is incorrect.


Is the binary correct and could be flashed, or is there an error I shoudl correct ?

@ISO-B
Copy link
Collaborator Author

ISO-B commented Jan 7, 2019

Binary is ok and can be flashed.

That error is expected since NXP's JN-SW-4170 has broken memsize.exe . Only thing that memsize.exe is used is to generate xls file that gives overview how firmware uses memory. You can remove memsize.exe command from Makefile then you don't get that error.

@KiwiHC16
Copy link

KiwiHC16 commented Jan 23, 2019

My expérience with @ISO-B description:
NXP

  • Studio 1308 / Win 7
  • Don't mix envirronement (Linux, OSX, Win) or you will waste hours and hours.
  • Follow ISO-B guide

from A to Z, don't skip any step.

PS: no issue for me with memsize.exe

@KiwiHC16
Copy link

KiwiHC16 commented Jan 24, 2019

I try a complementary approach to @ISO-B which looks to work, here after the differents steps:

As the compilation is closely linked to the folders organisation here is a solution I use to ease the dev.

You need to be admin to do next 2 commands:
capture d ecran 2019-01-24 a 12 37 34

First create a folder link with the command:
mklink /D C:\NXP\bstudio_nxp\workspace\ZiGate C:\NXP\bstudio_nxp\ZiGate\ModuleRadio\Firmware\src\ZiGate

Second create a folder link with the command:
mklink /D C:\NXP\bstudio_nxp\sdk\JN-SW-4170 "C:\NXP\bstudio_nxp\ZiGate\Module Radio\Firmware\src\sdk\JN-SW-4170"

Then we will use GitHub Desktop application to get the latest version. Start GitHub Desktop and "Clone a repository" from URL: https://github.com/fairecasoimeme/ZiGate.git
capture d ecran 2019-01-24 a 13 43 00

Select destination folder c:/NXP/bstudio_nxp/ZiGate

At this stage you should have a link in workspace
capture d ecran 2019-01-24 a 13 45 37

You shoul have a link in sdk:
capture d ecran 2019-01-24 a 14 42 40

and the complete ZIGate git in : C:\NXP\bstudio_nxp\ZiGate
capture d ecran 2019-01-24 a 13 46 21

Prepare sdk/JN-SW-4170 folder as per @ISO-B chapter "ZiGate latest development version":

  • Extract JN-SW-4170\Tools\ folder from zip to BeyondStudio-installation-path\sdk\JN-SW-4170\ and overwrite all duplicates
  • Find and remove all \r characters from .mk, .c, .h files
  • Library folders

When done, ready to start NXP Studio.

@KiwiHC16
Copy link

KiwiHC16 commented Jan 24, 2019

Let's start NXP IDE Studio, use default workspace or define it:
capture d ecran 2019-01-24 a 13 47 47

As per the description of @ISO-B above let's import the project:
capture d ecran 2019-01-24 a 13 48 43

Select the rigth folder (Verify that if you select with the mouse the path is right, I had to set it manually):
capture d ecran 2019-01-24 a 13 51 06

Click finish.

@KiwiHC16
Copy link

Time to compile:
capture d ecran 2019-01-24 a 13 53 55

and you should get this error:
capture d ecran 2019-01-24 a 13 54 16

So let's clean first:
capture d ecran 2019-01-24 a 13 54 42

Clic on little green target:
capture d ecran 2019-01-24 a 13 55 18

@KiwiHC16
Copy link

As a result you should have a target with clean key word:
capture d ecran 2019-01-24 a 13 55 56

Clic on clean to clean...
capture d ecran 2019-01-24 a 13 56 54

Time to compile:
capture d ecran 2019-01-24 a 13 57 13
Clic on little hammer.

@KiwiHC16
Copy link

KiwiHC16 commented Jan 24, 2019

capture d ecran 2019-01-24 a 13 59 40

Firmware bin is ready.

@KiwiHC16
Copy link

KiwiHC16 commented Jan 24, 2019

We compiled the master branche, let's compile the branche 3.0.f.
Back to github (close NXP Studio by default when you use GitHub to avoid conflicts)

First discard the changes and come back to master:
capture d ecran 2019-01-24 a 14 15 31

Select 3.0.f branche:
capture d ecran 2019-01-24 a 14 16 22

As we discarded all changes, we discarded also sdk modifications. So we have to reapply @ISO-B chapter "ZiGate latest development version".

Then start NXP Studio and create and clean target and then the Hammer to compile.
capture d ecran 2019-01-24 a 14 59 35

@ISO-B
Copy link
Collaborator Author

ISO-B commented Jan 24, 2019

One thing that would also help, if it's ok for @fairecasoimeme, to fix all those line-endings and commit files to git

@fairecasoimeme
Copy link
Owner

You're right,
I'll try to solve this issue this week-end ...

@fairecasoimeme
Copy link
Owner

done. Please tell me of it's ok for you. I'm newbie in github

@ISO-B
Copy link
Collaborator Author

ISO-B commented Jan 30, 2019

Sorry, took bit long before had time to test. All .mk, .c, .h files seem to be ok now.
There is still some locations that have broken files:

  • /Components/Library/
  • /Platform/DK2/Library/
  • /Platform/DK3/Library/
  • /Platform/DK4/Library/
  • /Tools/

I can replace those with working ones and make PR.

@fairecasoimeme
Copy link
Owner

Ok, I'll do that tomorrow
Thx !

@handfreezer
Copy link

Just to tell this issue is very usefull! Thanks!

@pipiche38
Copy link

It might be good that issue is translated into a web page for documentation purposes

@minhtan58
Copy link

Hi everyone
I get a problem When I build ZiGate v3.1a (final) project.
Use Zigate from https://pypi.org/project/zigate/ to connect to Coordinator,

  • Use ZiGate_coordinator_JN5169.bin (in forder bin) it connect ok.
  • Build JN5169-115200
    image
    => I can't open port to connect Coordinator
    Can you help me? I don't know what reason !!!

@badzz
Copy link
Contributor

badzz commented Jan 31, 2020

Hi everyone
I get a problem When I build ZiGate v3.1a (final) project.
Use Zigate from https://pypi.org/project/zigate/ to connect to Coordinator,

  • Use ZiGate_coordinator_JN5169.bin (in forder bin) it connect ok.
  • Build JN5169-115200
    image
    => I can't open port to connect Coordinator
    Can you help me? I don't know what reason !!!

you have to use 5168 not 5159

@badzz
Copy link
Contributor

badzz commented Apr 25, 2020

If you want to directly work in beyondstudio on your github repository, do the following on a already installed config

stop beyondstudio for NXP
delete, rename or move somewhere else the folders c:\nxp\bstudio_nxp\sdk\JN-SW-4170 and c:\nxp\bstudio_nxp\workspace\ZiGate

if your git repo is under c:\workfolder\ZiGate, then do the following

mklink /J c:\nxp\bstudio_nxp\sdk\JN-SW-4170 "C:\workfolder\ZiGate\Module Radio\Firmware\src\sdk\JN-SW-4170"
mklink /J c:\nxp\bstudio_nxp\workspace\ZiGate "C:\workfolder\ZiGate\Module Radio\Firmware\src\ZiGate"

after checking out branches, even more for older ones you will to make sure that your obj files are cleaned. In BeyondStudio for NXP , you will have to do Project -> Clean

@fairecasoimeme : should we move all this to a wiki page ?

@pipiche38
Copy link

@fairecasoimeme : should we move all this to a wiki page ?

There is a Wiki associated to the github itself, you can just use it

@pipiche38
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants