No announcement yet.

HOW-TO: Install Python on PremierWave EN or XN

This is a sticky topic.
  • Filter
  • Time
  • Show
Clear All
new posts

  • HOW-TO: Install Python on PremierWave EN or XN

    Here are the steps to install Python scripting on your PremierWave EN or PremierWave XN:

    - Sign up for a free Timesys LinuxLink account at
    - Click on Build BSP/SDK and Create a Project. Give your project a name, select the PremierWave product (EN or XN) as the Board
    - Create a Workorder, give it a name, and click Next. Keep defaults for kernel and libc. Keep clicking Next until you get to the Packages page
    - In the Packages page, expand Runtimes and select Python and Pyserial packages
    - Expand System and select ltrx-rfs-base and ltrx-fwupgrade. Click Next
    - Leave the defaults for Build Options and click Next. Then Click Build.

    Once the build is done you will get an email. We will now install the SDK in a Linux host (or a VMWare image running Linux)
    - Download (or premierwave-xn)
    - chmod +x
    - ./
    - Follow the prompts to install the SDK
    - Add the toolchain/bin directory of the SDK to your $PATH variable (in ~/.profile, for example)

    Expand the filesystem from the built image like this:

    - Create a directory to work in, for example ~/projects/fs and change to it
    - sudo tar xzf ~/timesys/premierwave/rfs/rootfs.tar.gz

    Now, we can edit the filesystem before we put that in the PremierWave. For example for development, you might want to add this to ~/projects/fs/etc/inittab:
    null::sysinit:/usr/bin/python /ltrx_user/ &
    This will make it so that every time the PremierWave boots, it will start a script named at /ltrx_user/. This is conveniently the base directory for the FTP server. So in development you can easily FTP a script up to the PremierWave and have it automatically execute at start up.

    For production, you would probably want to make that line:
    null::sysinit:/usr/bin/python /usr/local/bin/ &
    And also you would want to add your Python script at ~/projects/fs/usr/local/bin/

    That way now every time the PremierWave boots, it will run the Python scripts, and the deployment is just by flashing the new image we're creating.

    Once you've modified the filesystem to your liking, now it's time to create the ubifs filesystem file:
    - cd .. (you should be one directory higher than the filesystem, so ~/projects if you're following this example)
    - sudo ~/timesys/premierwave/toolchain/bin/mkfs.ubifs -m 512 -e 15872 -c 4096 -r ./fs -o rootfs.ubifs

    We'll now make it into an installable .rom image:
    - For PremierWave EN: ltrx-makeimage -t10 rootfs.ubifs -v7.3.0.1R2 -iP1 -pimg28672 -ptot0
    - For PremierWave XN: ltrx-makeimage -t10 rootfs.ubifs -v7.3.0.1R2 -iP2 -pimg28672 -ptot0

    Finally we'll combine it with the kernel image so we can flash both at the same time:
    - ltrx-makeimage -c ~/timesys/premierwave/uImage.rom-2.6.30-ts-armv5l rootfs.ubifs.rom premierwave-python.rom

    Now you're ready to install this on your PremierWave.

    If you're starting from a factory PremierWave, the filesystem in that image is less than 16MB. The filesystem in the image you created is 28MB (notice the -pimg28672 in the step making the filesystem image?). This means we have to re-partition the flash in the PremierWave when we install it. Not a problem, DeviceInstaller can do it for you.

    So here are the steps for this:
    1. Download DeviceInstaller from our website:
    2. Connect the PremierWave EN/XN to the computer with DeviceInstaller via serial cable
    3. In DeviceInstaller, start the Serial recovery by going to Tools->Recovery Firmware (or press F8)
    4. In the window that pops up, enter these values:
    a. Device Model: Select your device here
    b. Port on Device: whichever serial port on the EN/XN you connected the cable to
    c. Erase All Flash: make sure this checkbox is CHECKED (this will erase the flash so that it's re-partitioned)
    d. Firmware File: The premierwave-python.rom we just created
    e. Click on the Advanced>> button to bring up the advanced menu
    f. (This is only if you're having problems loading the image with older DeviceInstaller. Newer DeviceInstaller doesn't need the custom Recovery Loader) In Recovery Loader, use the custom loader you can download from here: (download the zip file, unzip it, then use the .rom file that you get as your recovery loader)
    5. Hit OK. This process will take a while (about 30 minutes)

    Notice that when you built the image, you selected not just ltrx-rfs-base, but also ltrx-fwupgrade. Why? So that after this first initial build, you can flash new .rom images through the web server in the PremierWave. As long as your new image's filesystem is not any larger than 28MB, you'll be able to use the System tab there to flash a new image.
    Last edited by mariano; 08-02-2013, 10:17 PM.