Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
manual:chapter1:buildfromsource [2018/01/03 12:30]
claudio [Building the firmware]
manual:chapter1:buildfromsource [2019/11/20 14:45] (current)
jojo1973
Line 1: Line 1:
-====== Building newRPL from source code ======+===== Building newRPL from source code =====
  
- +==== Preparing a system for compiling the simulator ====
-===== Preparing a system for compiling the simulator ​=====+
  
 **Linux** **Linux**
  
-The following instructions are for Ubuntu, package names might change slightly on other distros. +The following instructions are for //Ubuntu//, package names might change slightly on other distros.
- +
-Packages to install (either use synaptic package manager, or apt):+
  
-git\\ +Packages to install (either use //​synaptic//​ package manager, or //apt//):
-libelf-dev\\ +
-libudev-dev\\+
  
-If using other distros, verify that these other packages are installed:​\\ +<​code>​ 
-gcc\\ +git 
-g++\\ +libelf-dev 
-libc6-dev\\+libudev-dev 
 +</​code>​
  
-and for Qtsome 3D related headers (even though not used by newRPL) are needed, therefore ​these packages ​need to be installed ​as  well:+If using other distrosverify that these other packages ​are installed: 
 +<​code>​ 
 +gcc 
 +g++ 
 +libc6-dev 
 +</​code>​
  
 +and for //Qt//, some 3D related headers (even though not used by **newRPL**) are needed, therefore these packages need to be installed as  well:
 +<​code>​
 libgl-dev libgl-dev
 +</​code>​
  
 +Time to install the //Qt// framework.
  
-Time to install the Qt framework, go to [[http://​qt-project.org]] and download the open source version. It will download a file named '​qt-unified-....'change the permissions to allow executing it as a program and run it to install Qt.\\ +  - Go to [[http://​qt-project.org]] and download the open source version. It will download a file named ''​qt-unified-...'​'; 
-When it's time to select components, it's very important to open the lists and select a library version and target. **The installer will not select a library version by default**, and failing to select one will leave you without a proper library and unable to build newRPL. Select the latest Qt version (5.10.0 at the time of this writing), the only component needed is the one labeled ​"Desktop gcc 64-bits". Make sure at least that component is checked.+  - change the permissions to allow executing it as a program and run it to install ​//Qt//; 
 +  - when it's time to select components, it's very important to open the lists and select a library version and target. **The installer will not select a library version by default**, and failing to select one will leave you without a proper library and unable to build **newRPL**. Select the latest ​//Qt// version (5.10.0 at the time of this writing), the only component needed is the one labeled ​''​Desktop gcc 64-bits''​. Make sure at least that component is checked.
  
 **freeBSD** **freeBSD**
  
-In order to use Qt Creator, a graphical desktop needs to be installed (that'​s outside the scope of this article). +In order to use //Qt Creator//, a graphical desktop needs to be installed (that'​s outside the scope of this article).
-Packages to install (either using pkg or OctoPkg):+
  
-git\\ +Packages to install (either using //pkg// or //​OctoPkg//​):​ 
-qt5\\ + 
-qtcreator\\+<​code>​ 
 +git 
 +qt5 
 +qtcreator 
 +</​code>​
  
 And that's all that's required. And that's all that's required.
  
 For developers wishing to cooperate with the project, another package is needed: For developers wishing to cooperate with the project, another package is needed:
 +<​code>​
 gdb gdb
 +</​code>​
  
-Once the packages are installed, start Qt Creator, and navigate the menus and dialogs through Tools, Options... Build&​Run,​ Kits and select the Desktop (default) configuration. Verify ​that everything is populated, and change the Debugger to ''​System GDB at /​usr/​local/​bin/​gdb''​ which is the version of gdb that was just installed. This is needed only to debug the code, not needed if the objective is simply to have a running version of **newRPL Desktop**.+Once the packages are installed, 
 +  - start //Qt Creator//, and navigate the menus and dialogs through ​''​Tools''​''​Options...'',​ ''​Build&​Run''​''​Kits'' ​and select the ''​Desktop'' ​(default) configuration
 +  - verify ​that everything is populated, and change the Debugger to ''​System GDB at /​usr/​local/​bin/​gdb''​ which is the version of gdb that was just installed. This is needed only to debug the code, not needed if the objective is simply to have a running version of **newRPL Desktop**.
  
  
-===== Preparing a system for cross-compiling the firmware ​=====+==== Preparing a system for cross-compiling the firmware ====
  
 **Linux** **Linux**
  
-The following instructions are for Ubuntu, package names might change slightly on other distros. +The following instructions are for //Ubuntu//, package names might change slightly on other distros.
- +
-Packages to install (either use synaptic package manager, or apt):+
  
 +Packages to install (either use //​synaptic//​ package manager, or //apt//):
 +<​code>​
 gcc-arm-none-eabi gcc-arm-none-eabi
 +</​code>​
  
-Other packages like binutils-arm-none-eabi will be installed automatically,​ on other distros this might be different and it needs to be installed separately.+Other packages like 
 +<​code>​ 
 +binutils-arm-none-eabi 
 +</​code>​ 
 +will be installed automatically,​ on other distros this might be different and it needs to be installed separately.
  
 **freeBSD** **freeBSD**
  
-Packages to install (either use pkg or OctoPkg):+Packages to install (either use //pkg// or //OctoPkg//): 
 +<​code>​ 
 +arm-none-eabi-gcc 
 +</​code>​
  
-arm-none-eabi-gcc\\ 
  
 +==== Getting the source code ====
  
-===== Getting the source code ===== +**Linux** and **freeBSD**
- +
-**Linux**+
  
 While at your user's home, open a terminal and run: While at your user's home, open a terminal and run:
  
-git clone https://​git.code.sf.net/​p/​newrpl/​sources newrpl-sources+''​git clone https://​git.code.sf.net/​p/​newrpl/​sources newrpl-sources''​
  
 +----
  
 +==== Building the tools ====
  
-===== Building the tools =====+=== elf2rom ​===
  
-==== elf2rom ​====+The first tool that needs building is ''​elf2rom''​.
  
-The first tool that needs building ​is elf2rom.+  - Open //Qt Creator//, select ''​Open Project'',​ and go into ''​newrpl-sources/​tools/​elf2rom'';​ 
 +  - select the ''​elf2rom.pro''​ project file; 
 +  - when prompted, just click on ''​Configure project'';​ 
 +  - at the bottom-left of the screen, there will be an icon that looks like a screen and shows ''​Debug'':​ change it to ''​Release'';​ 
 +  - on the left toolbox, select the wrench ''​Projects''​ to access the build settings; 
 +  - make sure ''​Release'' ​is the selected configuration,​ then ''​Add Build Step''​ / ''​Make'',​ and in the ''​Make arguments:''​ box type ''​install'';​ 
 +  - now from the top menu, ''​Build'',​ ''​Run QMake'',​ then ''​Rebuild All'';​ 
 +  - from the bottom of the screen, check the ''​Compile Output''​ pane to see if everything went well. Quite often, the last step ''​make install''​ says there'​s nothing new to install when there'​s actually a newly built executable. Another round of ''​Run QMake''​ and ''​Rebuild All''​ usually shows in the output pane that the file is being copied to ''​newrpl/​tools-bin''​ which is the expected result.
  
-Open Qt Creator, select Open Project, and go into newrpl-sources/​tools/​elf2rom,​ then select ​the elf2rom.pro project file.+It's done: the ''​elf2rom''​ tool was built and installed in the appropriate location to be used by the other projectsSelect ''​Close all projects and editors''​ from the main menu to end the session.
  
-When prompted, just click on '​Configure project'​. +=== bmp2font ===
-At the bottom-left of the screen, there will be an icon that looks like a screen and shows '​Debug'​. Change it to '​Release'​. +
-On the left toolbox, select the wrench '​Projects'​ to access the build settings. +
-Make sure '​Release'​ is the selected configuration,​ then 'Add Build Step' / '​Make',​ and in the 'Make arguments:'​ box type '​install'​ (without quotes). +
-Now from the top menu, '​Build',​ 'Run QMake',​ then '​Rebuild All'​. +
-From the bottom of the screen, check the '​Compile Output'​ pane to see if everything went well. Quite often, the last step 'make install'​ says there'​s nothing new to install when there'​s actually a newly built executable. Another round of 'Run QMake' and '​Rebuild All' usually shows in the output pane that the file is being copied to newrpl/​tools-bin which is the expected result.+
  
-It's done, the elf2rom tool was built and installed in the appropriate location ​to be used by the other projects. Select ​'Close all projects ​and editors' from the main menu to end the session.+  - Open //Qt Creator//, select ''​Open Project'​', ​and go into ''​newrpl-sources/​tools/​fonts/​bmp2font'';​ 
 +  - select ​the ''​bmp2font.pro''​ project file; 
 +  - when prompted, just click on ''​Configure project'';​ 
 +  - at the bottom-left of the screen, there will be an icon that looks like a screen ​and shows ''​Debug'':​ change it to ''​Release'';​ 
 +  - on the left toolbox, select the wrench ''​Projects'' ​to access ​the build settings; 
 +  - make sure ''​Release''​ is the selected configuration,​ then ''​Add Build Step''​ / ''​Make'', ​and in the ''Make arguments:''​ box type ''​install'';​ 
 +  - now from the top menu, ''​Build'',​ ''​Run QMake'',​ then ''​Rebuild All'';​ 
 +  - from the bottom of the screen, check the ''​Compile Output''​ pane to see if everything went well. Quite often, the last step ''​make install''​ says there'​s nothing new to install when there'​s actually a newly built executable. Another round of ''​Run QMake''​ and ''​Rebuild All''​ usually shows in the output pane that the file is being copied to ''​newrpl/​tools-bin''​ which is the expected result.
  
-==== newRPL standalone compiler ====+It's done: the ''​bmp2font''​ tool was built and installed in the appropriate location to be used by the other projects. Select ''​Close all projects and editors''​ from the main menu to end the session.
  
-Open Qt Creator, select Open Project, and go into newrpl-sources,​ then select the newrpl-comp.pro project file.+=== newRPL standalone compiler ===
  
-When prompted, just click on '​Configure project'​. +  - Open //Qt Creator//, select ''​Open Project'',​ and go into ''​newrpl-sources'';​ 
-At the bottom-left of the screen, there will be an icon that looks like a screen and shows '​Debug'​. Change ​it to '​Release'​. +  - select the ''​newrpl-comp.pro''​ project file; 
-On the left toolbox, select the wrench '​Projects'​ to access the build settings. +  - when prompted, just click on ''​Configure project'​'; 
-Make sure '​Release'​ is the selected configuration,​ then 'Add Build Step' / '​Make',​ and in the 'Make arguments:'​ box type '​install' ​(without quotes). +  - at the bottom-left of the screen, there will be an icon that looks like a screen and shows ''​Debug'​': change ​it to ''​Release'​'; 
-Now from the top menu, '​Build',​ 'Run QMake',​ then '​Rebuild All'. +  - on the left toolbox, select the wrench ​''​Projects'' to access the build settings; 
-From the bottom of the screen, check the '​Compile Output'​ pane to see if everything went well. Quite often, the last step 'make install'​ says there'​s nothing new to install when there'​s actually a newly built executable. Another round of 'Run QMake' and '​Rebuild All' usually shows in the output pane that the file is being copied to newrpl/​tools-bin which is the expected result.+  - make sure ''​Release'' is the selected configuration,​ then ''Add Build Step'' / ''Make'', and in the ''Make arguments:'' box type ''​install'​'; 
 +  - now from the top menu, ''Build'', ​''Run QMake'', then ''​Rebuild All''; 
 +  - from the bottom of the screen, check the ''​Compile Output'' pane to see if everything went well. Quite often, the last step ''make install'' says there'​s nothing new to install when there'​s actually a newly built executable. Another round of ''Run QMake'' and ''​Rebuild All'' usually shows in the output pane that the file is being copied to ''​newrpl/​tools-bin'' ​which is the expected result.
  
-Finished, ​the newrpl-comp tool was built and installed in the appropriate location to be used by the other projects.+It's done: the ''​newrpl-comp'' ​tool was built and installed in the appropriate location to be used by the other projects. Select ''​Close all projects and editors''​ from the main menu to end the session.
  
-===== Building the Desktop simulator =====+----
  
-Open Qt Creator, select Open Project, and go into newrpl-sources,​ then select ​the newrpl-ui.pro project file.+==== Building ​the newRPL desktop simulator ====
  
-When prompted, just click on '​Configure project'​. +  - Open //Qt Creator//, select ''​Open Project'',​ and go into ''​newrpl-sources'';​ 
-At the bottom-left of the screen, there will be an icon that looks like a screen and shows '​Debug'​. Change ​it to '​Release'​. +  - select the ''​newrpl-ui.pro''​ project file; 
-Now from the top menu, '​Build',​ 'Run QMake',​ then '​Rebuild All'. +  - when prompted, just click on ''​Configure project'​'; 
-From the bottom of the screen, check the '​Compile Output'​ pane to see if everything went well. There might be some warningsbut there should be no hard errors.+  - at the bottom-left of the screen, there will be an icon that looks like a screen and shows ''​Debug'​': change ​it to ''​Release'​'; 
 +  - on the left toolbox, select the wrench ''​Projects''​ to access the build settings; 
 +  - make sure ''​Release''​ is the selected configuration,​ then ''​Add Build Step''​ / ''​Make'',​ and in the ''​Make arguments:''​ box type ''​install'';​ 
 +  - now from the top menu, ''Build'', ​''Run QMake'', then ''​Rebuild All''; 
 +  - from the bottom of the screen, check the ''​Compile Output'' pane to see if everything went well. Quite oftenthe last step ''​make install''​ says there's nothing new to install when there'​s actually a newly built executable. Another round of ''​Run QMake''​ and ''​Rebuild All''​ usually shows in the output pane that the file is being copied to ''​newrpl-sources''​ which is the expected result.
  
-At the lower left area of the screen, use the upper 'Play' ​button (Run without debugging) ​to start the application.+It's done: the ''​newrpl-ui''​ tool was built and installed in the appropriate location to be used by the other projects. Select ​''​Close all projects and editors''​ from the main menu to end the session.
  
-===== Building ​the firmware =====+At the lower left area of the screen, use the upper //Play// button (Run without debugging) to start the application.
  
-Open Qt Creator, select Open Project, and go into newrpl-sources,​ then select ​the newrpl-fw.pro project file for the 50g target. Other project files are available for the other targets, follow exactly the same instructions for all targets.+==== Building ​the firmware ====
  
-When prompted, just click on '​Configure project'​.+  - Open //Qt Creator//, select ''​Open Project'',​ and go into ''​newrpl-sources'',​ then select the relevant project file: ''​newrpl-fw.pro''​ for the **50g** target, ''​newrpl-fw39.pro''​ for the **39g+ / 39gs** target, ''​newrpl-fw40.pro''​ for the **40gs** target; 
 +  - when prompted, just click on ''​Configure project'​'; 
 +  - open a Terminal window and type<​code>​ 
 +arm-none-eabi-gcc -print-libgcc-file-name 
 +</​code>​It will print the full path to a file called ''​libgcc.a''​. Remember that path (without the ''/​libgcc.a''​ part); 
 +  - back to //Qt Creator//, from the left pane open the file ''​newrpl-fw.pro'',​ and scroll down to a line that reads<​code>​ 
 +GCC_LIBDIR = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx</​code>​Change that path to match exactly the path we got from the previous step; 
 +  - one last check: locate the line that reads<​code>​ 
 +INCLUDEPATH += firmware/​include newrpl xxxxxxxxxxxxxxx 
 +</​code>​The ''​xxxxxxxxxxxxxxx''​ should point to suitable headers. In particular on a 64-bit system the system headers might be incompatible and cause errors. The first attempt should be to keep the defaults, and if any errors appear, to change it to ''/​usr/​include/​newlib''​ (or wherever there'​s a suitable 32-bit library). While **newRPL** will not link to or use the library in any way, some standard headers are expected to provide definitions;​ 
 +  - another possible alternative for 64-bit systems is to install the package<​code>​ 
 +libc6-dev-i386 
 +</​code>​ which in most cases should allow to keep the default directories. For //Ubuntu// it works with the defaults, for other systems change that to ''/​usr/​include/​newlib'',​ so the line reads<​code>​ 
 +INCLUDEPATH += firmware/​include newrpl /​usr/​include/​newlib</​code>​ 
 +  - save and close the file; 
 +  - now from the top menu, ''​Build'',​ ''​Run QMake'',​ then ''​Rebuild All'';​ 
 +  - from the bottom of the screen, check the ''​Compile Output''​ pane to see if everything went well. There might be some warnings, but there should be no hard errors. There could be many warnings, depending on your version of //gcc// and your system: these warnings change all the time but they are harmless. 
 +   
 +To verify that it completed the build, the last output line should read
  
-Open a Terminal window and type:+''​Binary image written to "​newrplfw.bin"''​ (for HP50g target) or\\ 
 +''​Binary image written to "​newrpl39.bin"''​ (for HP39g+ / 39gs target) or\\ 
 +''​Binary image written to "​newrpl40.bin"''​ (for HP40gs target)
  
-''​arm-none-eabi-gcc -print-libgcc-file-name''​+If you see that line, everything went well, and your build directory (usually named ''​build-newrpl-fw-Desktop...''​) will contain the firmware file, which is the ROM that needs to be flashed on the calculator.
  
-It will print the full path to a file called libgcc.a. Remember that path (without the file /libgcc.a). Back to Qt Creator, from the left pane open the file newrpl-fw.pro, and scroll down to a line that reads:+----
  
-''​GCC_LIBDIR ​xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx''​+==== Updating the source tree to a new version ====
  
-Change that path to match exactly the path we got from the previous step. +When updates are made to the source tree
- +
-One last check, the line that reads: +
- +
-''​INCLUDEPATH += firmware/​include newrpl xxxxxxxxxxxxxxx''​ +
- +
-The xxxxxxxxxxxxxx should point to suitable headers. In particular on a 64-bit system the system headers might be incompatible and cause errors. The first attempt should be to keep the defaults, and if any errors appear, it needs to be changed to /​usr/​include/​newlib (or wherever there'​s a suitable 32-bit library). While newRPL will not link to or use the library in any way, some standard headers are expected to provide definitions. +
-Another possible alternative for 64-bit systems is to install the package libc6-dev-i386,​ which in most cases should allow to keep the default directories. +
-For Ubuntu it works with the defaults, for other systems change that to /​usr/​include/​newlib,​ so the line reads: +
- +
-''​INCLUDEPATH += firmware/​include newrpl /​usr/​include/​newlib''​ +
- +
-Save and close the file. +
-  +
-Now from the top menu, '​Build',​ 'Run QMake',​ then '​Rebuild All'​. +
-From the bottom of the screen, check the '​Compile Output'​ pane to see if everything went well. There might be some warnings, but there should be no hard errors. There could be many warnings, depending on your version of gcc and your system these warnings change all the time but they are harmless. +
-To verify that it completed the build, the last output line should read: +
- +
-Binary image written to "​newrplfw.bin"​ +
- +
-If you see that line, everything went well, and your build directory (usually named build-newrpl-fw-Desktop....) will contain the newrplfw.bin file, which is the ROM that needs to be flashed on the calculator. +
- +
-===== Updating the source tree to a new version ===== +
- +
-When updates are made to the source tree, open a terminal session and go inside the main source directory (usually newrpl-sources),​ and issue:+
  
 +  - open a terminal session and go inside the main source directory (usually ''​newrpl-sources''​),​ and issue<​code>​
 git pull git pull
- +</​code>​This will update the source code to the lastest version
-This will update the source code to the lastest version. Open QtCreator and open the newrpl-comp.pro project. On the  Build menu, "Run QMake" then "​Rebuild all". Check the compile output to make sure the new version was copied to newrpl/​tools-bin,​ if not then repeat the steps "Run QMake" ​and "Rebuild all". +  - [[buildfromsource#​newrpl-standalone-compiler|build ​the standalone compiler]] and check the compile output to make sure the new version was copied to ''​newrpl/​tools-bin''​, if not then repeat the steps ''​Run QMake'' ​and ''​Rebuild all'';​ 
- +  - with the updated compiler in place, close all projects ​and [[buildfromsource#​building-the-newrpl-desktop-simulator|rebuild the desktop simulator]]. The ''​Run QMake'' ​step is not optional, ​it needs to be manually executed to make sure the build number is updated, otherwise the ''​[[manual:​chapter6:​system:​cmd_version|VERSION]]'' ​command will report the incorrect build number; 
-With the updated compiler in place, close all projects, open newrpl-ui.pro and do "Run QMake" then "​Rebuild all". The "Run QMake" ​step is not optional, needs to be manually executed to make sure the build number is updated, otherwise the VERSION command will report the incorrect build number. +  - finally, close all projects and [[buildfromsource#​building-the-firmware|rebuild the firmware]].
- +
-Finally, close all projects and open newrpl-fw.pro (or the equivalent for other hardware targets), and also "Run QMake" and "​Rebuild all". +
  • manual/chapter1/buildfromsource.1515011424.txt.gz
  • Last modified: 2018/01/03 12:30
  • by claudio