[How to] Build the LXR firmware code on MAC OS 10.8 and above

Hello,
First of all, I would like to thanks @Rudeog, @Pld, @TB323, @Julian and @spfrc for their great help with me :-) I must have forgot some names who helped me, sorry in advance :-)

Tutorial to build the firmware for MAC OS 10.8 and above:

Note 1 - The installation steps are rather simple as I don't use anymore ECLIPSE. Indeed, configuring Eclipse on MAC to compile the code is rather tricky for a beginner like me.

Note 2 - The LXR code is divided into two mains code parts that we will compile "separately" using two different tools :-)
  1. the AVR Atmel CODE (LCD, front panel control, USB, SD card)
  2. the ARM CODE (main LXR code for the voices / sounds)
General steps:
We need "specific compilers and librairies" for each CODE.
We need to change the PATH in your .bash_profile, and finally we need MAKEFILES to build the firmware:
  1. AVR AtmelCODE  -> command/libs avr-gcc
  2. GNU ARM CODE --> command/libs arm-eabi-none-gcc
  3. Change PATH on your MAC -> I will provide an exemple later.
  4. LXR Code  -> We need the LXR code that we will download later.
  5. MACOS specific MAKEFILES  -> We need special makefileS that @PLD has provided. I will give you the links later
  6. Compiling and build the firmware.bin file-> You just have to launch the command "make firmware" from a MAC terminal window.
Let's start!

1- AVR COMPILER & LIBS:
- Download of Atmel AVR 8-bit toolchain from http://www.obdev.at/products/crosspack/download.html
- You will get a .dmg file that you should extract and install (CrossPack-AVR-20131216.dmg is the most recent as of 2015/05/02)
- The compiler and libs are installed under /usr/local/CrossPack-AVR-20131216/
- Note that you will also find a folder like /usr/local/CrossPack-AVR/ (this folder is an alias to the previous folder - symlink).

2- GNU ARM COMPILER AND LIBS
- Download of GNU bare metal ARM toolchain from https://launchpad.net/gcc-arm-embedded (v4.8)
- Take the MAC version (something like : gcc-arm-none-eabi-4_8-2014q1-20140314-mac.tar.bz2 )
- Extract the compressed/tar file.
- Copy the extracted folder under /usr/local/
- Nothing else to do !

3- Change your PATH
- We need to add a specific PATH for both compilers (and libs) for the MAC. Here is mine...

export PATH=$PATH:/usr/local/CrossPack-AVR-20131216/bin:/usr/local/CrossPack-AVR-20131216/:/usr/include:/usr/local/CrossPack-AVR-20131216/avr/include:/usr/local/gcc-arm-none-eabi-4_8-2014q1/bin
export ARM_TOOLKIT_ROOT=/usr/local/gcc-arm-none-eabi-4_8-2014q1
export AVR_TOOLKIT_ROOT=/usr/local/CrossPack-AVR-20131216

- in a terminal window, execute "source ./.bash_profile" to update the PATH to your system.
- for the moment, don't try to understand what are ARM_TOOLKIT / AVR_TOLLKIT variables, I will explain why we need this later.

4- Grab the LXR Code
I advice you to grab the code either from :
  1. Julian repository on GITHUB (https://github.com/SonicPotions/LXR) -> but you may have issues as this code contains wrong backslashes in certain area of the code. Should be soon fixed.
  2. PLD repository (https://github.com/patrickdowling/LXR) -> but you may also have issues with this code containing wrong backslashes in certain area of the code.
  3. rudeog repository (https://github.com/rudeog/LXR) -> this one is OKAY with extra features compared to Julian code.
  4. rstephane repository (https://github.com/rstephane/LXR) -> this one is OKAY, it is equivalent to Julian CODE without the wrong backslashes.

- of course once downloaded, you should extract the code and copy it to any folder you like.
On my side I did copied it under: /Users/music/Documents/workspace/LXR/

5- MACOS specific makefiles 
I advice you to grab the makefiles either from :
  1. PLD repository (https://github.com/patrickdowling/LXR
  2. rstephane (@egnouf) repository (https://github.com/rstephane/LXR)
  3. RUDEOG repository https://github.com/patrickdowling/LXR
- You will find on the root path of both repository a file called MAKEFILE. You will also need the other makefiles:
  1. https://github.com/patrickdowling/LXR/blob/makefiles/Makefile
  2. https://github.com/patrickdowling/LXR/blob/makefiles/front/AVR/Makefile
  3. https://github.com/patrickdowling/LXR/blob/makefiles/mainboard/firmware/DrumSynth_FPU/Makefile
  4. https://github.com/patrickdowling/LXR/blob/makefiles/tools/FirmwareImageBuilder/Makefile
Once downloaded, copy them at the root PATH of the code (1) and in subfolders (2,3,4) you dowloaded in STEP 4.

Notes:
- If you have taken the whole LXR code from @PLD or rstephane (@egnouf) or @RUDEOG you don't need to download once more the Makefiles, they are provided within !
- the Makefiles of rstephane are a copy of the one provided by @PLD

Now, let's go back to the .bash_profile file:

export
PATH=$PATH:/usr/local/CrossPack-AVR-20131216/bin:/usr/local/CrossPack-AVR-20131216/:/usr/include:/usr/local/CrossPack-AVR-20131216/avr/include:/usr/local/gcc-arm-none-eabi-4_8-2014q1/bin
export ARM_TOOLKIT_ROOT=/usr/local/gcc-arm-none-eabi-4_8-2014q1
export AVR_TOOLKIT_ROOT=/usr/local/CrossPack-AVR-20131216

You can notice the two variables ARM_TOOLKIT_ROOT and AVR_TOOLKIT_ROOT.
They are used by the MAKEFILE that has created @PLD (and also used by rstephane).
- Change their values appropriately, according to your system path, where you installed the libs... etc.

6- Compile
  1. You just have to launch the command "make firmware" from a MAC terminal window. To clean the code you can execute "make clean".
  2. You will get a FIRMWARE.BIN image (in fact, we compiled two programs and the makefile combine both to one single file !), copy this file on your SD CARD and follow instruction to upload your new firmware.
7- Final note and test 
If you have downloaded rstephane code, similar to @Julian and @PLD, you will noticed that when you power on the machine, it displays "LXR-Drums-V" instead of "LXR Drums V". If so, you have successfully loaded (and compiled) LXR CODE!!!!


Well done and happy hacking!
:-)

«1

Comments

  • Excellent! :) Hopefully this will trigger some people to start coding fun features for the LXR.
  • Nice work @egnouf :)

    Btw, I didn't need to alter the PATH variable to get things to compile; just setting ARM_TOOLKIT_ROOT and AVR_TOOLKIT_ROOT worked for me.

    Also, here's a temp recipe to get the Makefiles (is there a better way to do this with git?)

    git clone -b makefiles https://github.com/patrickdowling/LXR.git LXR-pld
    (cd LXR-pld && tar -cf - $(find . -name Makefile)) | (cd LXR; tar -xf -)

    Now you've got everything in the LXR local directory.
  • Wow, great work :)
    Just a few quick notes:
    • You can probably simplify things a bit: the {AVR|ARM}_TOOLKIT_ROOT settings should be all that's needed, so you don't have to update your PATH, and they can be passed directly to make without adding them to your profile
    • @spfrc has used the same makefiles successfully on Linux: http://forum.sonic-potions.com/discussion/comment/5076#Comment_5076 (except I guess it needs an additional fix)
    • You can specify a different filename than FIRMWARE.BIN by using "make firmware FIRMWARE=xxx" or a different location using "make firmware DESTDIR=/tmp/"
    • There are 4 makefiles in total (root, tools, front, mainboard) and in my repo, they're in the 'makefiles' branch
    Let me know if there are any issues with the makefiles!
  • pldpld
    edited May 2014
    Heh, I spend too long typing :)
    There's probably at least two ways to do it with git:

    git fetch pld
    git checkout -b mybuild pld/path_fixes
    # git checkout -b mybuild pld/makefiles

    or

    git fetch pld
    git checkout -b mybuild
    git merge pld/path_fixes
    #git merge pld/makefiles

    Didn't test these, so there might be booboos :)
    Then you are working on a local 'mybuild' branch with everything merged.

    edit: branches that should actually compile. Or use egnouf's repo
  • http://git-man-page-generator.lokaltog.net

    I did something horrible with rebase as well, bleh.

    Of course, the main repo still needs a bunch of backslash fixes, so that would need a merge from rudeog's repo.
  • Narf, there's conflicts merging with rudeog's repo, so don't try that yet...
    I'll try and remember to push the path fixes to mine later, or just use egnouf's repo or your shell-voodoo.
    There should be a way to do it with cherry-pick or rebase, but I tend to stay away from that 8-}

  • Yeah, that's why I ended up with the cheesy tar copy ;)
  • Had to give it another try:

    git clone git@github.com:rudeog/LXR.git && cd LXR
    git fetch pld
    git checkout -b mybuild
    git cherry-pick d45348f5d7^..a2e69e81a9

    Not sure how well you can pull further changes using this, but it compiled so Good Enough :) 

  • I don't have time to test right now, but I can add these makefiles to my tree as well. I'm looking at @pld's makefile branch... are those the latest 4 makefiles?
    Hopefully I can get them tested on windows as well at some point.
  • @rudeog they're the Makefiles I used to test Linux & Mac builds, copied into a local clone of your repository.
  • Hello :-)
    on my side, I took the rudeog repository code and added the different makefile (coming from Patrick @pld). that's not all, then I had to replace the folder "tools" (in the rudeog repository) by the one provided by @PLD. Otherwise I get a compilation target error, can't build target bin, cortex, etc...

    now, the system compiles fine the code of rudeog on a MAC OS !
    have a good night!



  • I've added these 4 makefiles to my master
  • @rudeog great, thanks.

    Not sure if I still have a Windows install to test it with, but I don't think they'll work for Windows out of the box. I used some shell commands (find) and the firmwareBuilder project uses the local 'CXX'...
    Might be easier just to use cygwin or mingw?

  • I use mingw, so I'll test with that.
  • edited May 2014
    great! I just merged with rudeogs and plds changes for the official repo.
    after some further testing I will probably upload it tomorrow.

    I already added the build instructions for the linux build to the readme file.
    I will also include egnouf OSX instructions.

    Maybe I will also test the makefiles on windows, would be great to have a unified build environment that works on all systems. Getting the makefiles to build on Linux was MUCH more straight forward than setting up eclipse!

    I think I could try cygwin or an eclipse makefile project import for win.
  • I'm having a weird problem on Windows with mingw make... It seems to generate the correct command, but arm-gcc reports that it can't find a header file (as though I had not added the -I include path). If I copy and paste the command and run it from the command line it works fine, just not when launched via mingw32-make. I even dumped the current working dir right before (in the makefile) and it looks fine. Tried messing around with forward slashes, backslashes etc, and putting the full path in the -I, but still has a problem. Pretty weird.
  • @rudeog: just verified Windows builds work OK with Cygwin (using GNU make), so perhaps there's something odd about mingw make?

    One side note: Windows builds need an initial make clean to get the firmware builder regenerated correctly.
  • @rudeog
    That is weird. Which header file is it?
    Hm, is there maybe a space in the include path somewhere that needs to be quoted?
  • I'll try cygwin. It's occurring with all files in the ARM side, and it's not related to spaces, as none of my paths have spaces. Also the command succeeds fine when run from the command line.
  • Ok, cygwin works without any changes to the makefile (note to self, avoid mingw).
    So to add to the instructions...
    Windows Build
    Follow instructions 1 to 4 above
    Install Cygwin from http://cygwin.com/install.html
    During installation, add the following which are in the "Devel" item in the tree:
    -gcc-g++
    -make
    Open a cygwin terminal, and cd to the root of your LXR tree
    set the two aforementioned environment variables
    run make firmware

    The only trouble one may run into is that the makefiles use "find" to determine which source to compile. If using eclipse you might have one or more .c files under .metadata (for what reason, I don't know), so be sure to remove these.

  • Ah, good point. I'll fix it to exclude .files just in case.
    Something like this should work:
    find $(SRCDIR) -name "*.c" -print | grep -v '/\.'
  • http://wiki.sonic-potions.com/index.php/LXR_Windows_build_instructions

    Needs a little update to the install paths (Windows machine at home), but mostly there.
  • nice! thanks for updating the wiki, too!

    I still have to do some testing with the upcoming v0.33, but the fixed and merged code with the makefiles should be up in my repo by the end of the week.
  • edited May 2014
    I followed carrefully the step by step above on my mac to compile the firmware "LXR-Fusion" but I get this error: 

    /bin/sh: /bin/arm-none-eabi-gcc: No such file or directory

    It can't find  this file even it is where it should be and I also adapted my .bash_profile with the respective path.

    Any idea what I made wrong?



  • edited May 2014
    it means bash can't find the arm-none-eabi-gcc executable.
    can you print your path settings ('echo $PATH')
    I had a problem like this with an error in the first makefiles.
    The makefile added /bin/ to the path automatically.
    So the resulting path was .../bin/bin/

    are you using the makefiles from my (sonic-potions) repository in the latest version?

    can you launch 'arm-none-eabi-gcc' directly from bash?
  • Yeah, try it with the latest makefiles from Julian's reposistory, looks like LXR-Fusion doesn't have the latest ones. But it should also work if you set AVR_TOOLKIT_ROOT instead of relying on the executables being found in the path.
  • edited May 2014
    Hello :-)
    That's true I did not yet merged your new makefiles with the main branch :-)

    You have to set AVR_TOOLKIT_ROOT in the .bash file on your mac.
    (export AVR.... = the path)
    Tell me if you need more details about this part :-)

    Other notes
    The LXR-Fusion is under DEV.
    The code contains a lot of experimental add-on which are not called but present as a function (check the sequencer file, distortion file, drumvoicefile). I also tried to add comments to help ;-)

    I arrive to a point where I need:
    - as a good practice, merge the new LXR makefiles to my branch :-)
    - finish the function RANDOM, you will be able to RND more parameters :-)
    - I am playing a lot with the OTO effect, very nice!
    - I would like to improve the Loop Divide function
    - I would like to add more effect but I am stack on the number of sub page you can get (only two per section).
    - I need to refresh values when I do a random
    - I need to refresh the step sequence when playing with pre filled pattern

    anyhow, I am addicted to code the LXR !!! I can put the function I aswell wanted !!!
    :-)

  • edited May 2014
    it works fine with the latest makefiles from Julian's reposistory!
    @egnouf: I'll try again to compile the LXR-Fusion but actually I'm mainly interested to see how you implemented the extra FX.
    Thanks!
  • Yes, I understand :-)
    well, if you take my code and you declare the export stuff in your bash profile, it should work.
    I need to merge the new makefoile to my branch , I will test it this week-end and tell you more next week :)
Sign In or Register to comment.