How to build the neuros code (Neuros-Cooler, Nano-X, etc) in SB

From The Neuros Technology Wiki

Jump to: navigation, search

Warning: This guide is a work still in progress.. In other words, I'll be updating it frequently with my findings, and revising parts of it so that the process will go smoother. If you try something and it doesnt work, double check this guide. If it still doesnt work, bug fireether in the IRC chat room.

  • You have been warned.*

Note: Please do not modify this until its finished (and this note has been removed) without asking Fireether first.


Introduction

Why do I want to build the whole neuros code in ScratchBox? Not just because I can, but also because scratchbox has some advantages over using the toolchain that comes with the neuros source code.

  • You can run any programs that do not require graphics in scratchbox, and thus develop/debug them. This excludes OSDMain, but you can mount the OSD's root over NFS to a folder inside your scratchbox environment and copy the compiled OSDMain, then test it.
  • To compile a new program, you just download it, untar/unzip it, then compile it normally. Since building the neuros source code in scratchbox does copy some of the header files and libraries into /lib and /usr/include as a side effect, that can be a benefit to compile new programs that need those.
  • Since the scratchbox environment is seperated from the real root on your computer, you dont have to worry about screwing up your system as long as you stay within the environment.
  • The scripts that I wrote (along with instructions) will help to build each individual piece of the whole "puzzle". This is opposite of what the neuros build script does, which can save alot of time if you want to just rebuild nano-x instead of rebuilding everything over again.
  • You dont have to mess with cross compiler environmental variables when building new code.



Requirements

  • Scratchbox has to be installed. I used the binary tarballs from the scratchbox website.

You can use the debian version, but keep in mind that you do not need debian to make scratchbox work. http://www.scratchbox.org/download/files/sbox-releases/apophis/tarball/scratchbox-core-1.0.6-i386.tar.gz http://www.scratchbox.org/download/files/sbox-releases/apophis/tarball/scratchbox-devkit-cputransp-1.0.1-i386.tar.gz http://www.scratchbox.org/download/files/sbox-releases/apophis/tarball/scratchbox-libs-1.0.6-i386.tar.gz http://www.scratchbox.org/download/files/sbox-releases/apophis/tarball/scratchbox-toolchain-arm-linux-ct401-2.3-1.0.4-i386.tar.gz

Untar all in this way: tar -zxvf (name) -C /


Copy and paste the following code into it... for d in linux-r3-* Nano-X neuros-bsp Neuros-Cooler ; \ do svn switch svn://svn.neurostechnology.com/svn/$d/tags/OSD_VER_3.25-0.27_061117/ $d; done

    • Run it, and it will update your 3.19-0.15 to 3.25-0.27_061117.



How to compile under Scratch Box

Step 1 - Doing the Rootfs

-Goto neuros-bsp -make -f scripts/Makefile.fs base_rootfs (untested)

I prefer not to use sudo, because in SB, we dont have sudo. Plus, we run in usermode anyways. So if you dont have sudo installed, the above script will give an error when it tries to run sudo or su. At that point, do this:

scripts/mktargetnodes.sh --devdir=rootfs/fs/dev

scripts/mktargetetc.sh --etcdir=rootfs/fs/etc

  • Note* - you NEED to be root to run the above scripts. However, you cannot SB as root.

So what to do? Do this:

-Open a new terminal window, with yourself as root. -Goto the scratchbox dir for that user (example below)

/OSD/scratchbox/users/noah/home/noah/neuros-osd/neuros-bsp/

And re-run the scripts. You do NOT have to set any environmental variables, the scripts just create the base system.

<maybe not done>


Step 2 - Doing Nano-X

To build, follow this:

Easier script:

(run this at Nano-X's parent dir) - name it MakeNano-X.

echo "Nano-X has two requirements. JPEG and freetype1. Those will be build along with Nano-X."
echo "This script only builds, it does not clean."
echo "Waiting 5 seconds before starting. Feel free to take this out."
sleep 5

echo;echo;echo;
echo "Building JPEG support now.."
echo "Waiting 2 seconds before starting. Feel free to take this out."
sleep 2
cd Nano-X/src/contrib/jpeg
./configure --host=arm-linux --prefix='${PWD}/../..'
make libjpeg.a
make install-lib

echo;echo;echo;
echo "Building Freetype1 support now.."
echo "Waiting 2 seconds before starting. Feel free to take this out."
sleep 2
cd ../freetype1
./configure --host=arm-linux --prefix=${PWD}/../.. --disable-shared --enable-static --disable-nls
make clean
make ttlib
make install-lib

echo;echo;echo;
echo "Building Nano-X now.."
echo "Waiting 2 seconds before starting. Feel free to take this out."
sleep 2
cd ../../
make
cd ../../ 
echo "Done with Nano-X build!"

Step 3 - doing Neuros-Cooler

      • Note*** You must have your rootfs setup before doing this.

This one is tougher. It uses a makefile, which will panic if you didnt source the BSP environment. It also looks for BSP_ROOT var, which is not set by the neuros-env.

Also, if you have not copied files from /neuros-bsp/toolchain/arm-linux/include/linux/ to /neuros-bsp/kernels/linux/include/, then you will have problems building the watchdog, which is one of the many neuros-bsp builds.

To fix:

# Edit below to your settings.
PROJECT=neuros-bsp
PRJROOT=/home/noah/neuros-osd/${PROJECT}
BSP_ROOT=${PRJROOT}
ROOTFS=${PRJROOT}/rootfs
INSTALL_MOD_PATH=${ROOTFS}/fs
SU=sudo
export PROJECT PRJROOT BSP_ROOT ROOTFS INSTALL_MOD_PATH SU


cd Neuros-Cooler/build

# In case it doesnt exist..
mkdir /usr/include/linux

cp ../../neuros-bsp/toolchain/arm-linux/include/linux/irrtc.h /usr/include/linux
cp ../../neuros-bsp/toolchain/arm-linux/include/linux/leds.h /usr/include/linux
cp ../../neuros-bsp/toolchain/arm-linux/include/linux/itfb.h /usr/include/linux

# Again, in case it doesnt exist..
mkdir /usr/include/asm/arch/

cp ../../neuros-bsp/kernels/linux-2.6.15/include/asm-arm/arch-ntosd-dm320/gio.h /usr/include/asm/arch
cp ../../neuros-bsp/kernels/linux-2.6.15/include/asm-arm/arch-ntosd-dm320/gios.h /usr/include/asm/arch

make cleanall
make all
make install

# Copy the library to the correct path.
# Otherwise mainapp will have problems building.
cp libncooler.so /lib


Step 4 - linux-r3-main-app

Since we didnt run the bsp script (makerootfs) and make menuconfig in neuros-bsp, we'll have to generate the bsp_config.h by hand OR by copying over a default config. The latter method is what I picked.

What I did was to take the default config from an image that I already made, and then used that.

Warning: This is not complete. Things **CAN** break if the defaults change. Its recommended to generate your own bsp config, for now. I'll see if I can figure out how to generate it without having to do this.


/*
 * Automatically generated header file: don't edit
 */

#ifndef __BSP_CONFIG_H
#define __BSP_CONFIG_H

#define AUTOCONF_INCLUDED

#define NEUROS_BSP 1

/*
 * Build Configuration
 */
#define USING_CROSS_COMPILER 1
#define CONFIG_INSTALL_NO_USR 1
#define CONFIG_IMAGES_PREFIX "images"
#define CONFIG_SYSAPPS_PREFIX "rootfs/fs"
#define PREFIX "rootfs/fs"

/*
 * Memory Device Configuration
 */

/*
 * SDRAM Configuration
 */
#define CONFIG_NR_DRAM_BANKS 1
#define PHYS_SDRAM_1 0x01100000
#define PHYS_SDRAM_1_SIZE 0x04000000

/*
 * Flash Configuration
 */
#define CFG_MAX_FLASH_BANKS 1
#define PHYS_FLASH_1 0x00100000
#define PHYS_FLASH_SIZE 0x01000000
#define CFG_MAX_FLASH_SECT 270
#define CFG_FLASH_8BIT_MODE 1
#undef CFG_FLASH_16BIT_MODE

/*
 * Kernel Memory Configuration
 */
#define CONFIG_KERNEL_LOAD_ADDR 0x01108000
#define CONFIG_KERNEL_PARAM_ADDR 0x01100100
#define CONFIG_KERNEL_INITRD_ADDR 0x01800000
#define CFG_KERNEL_MEM_RESERVE 14

/*
 * U-Boot Bootloader Configuration
 */
#undef CONFIG_NTDEV_DM320
#undef CONFIG_NTR3_DM320
#define CONFIG_NTOSD_DM320 1
#undef CONFIG_DM320_30
#undef CONFIG_DM320
#undef CONFIG_DM270
#undef CONFIG_DM275
#undef CONFIG_DCIII
#undef CONFIG_DM340
#undef CONFIG_DM420
#undef CONFIG_OMAP2430
#define CONFIG_BOARD_CONFIG "ntosd-dm320_config"
#define CONFIG_ARM926EJS 1
#undef CONFIG_ARM_CLOCK175
#define CROSS_COMPILER_PREFIX "arm-linux-"
#define BOARD_POST_INIT 1
#undef CONFIG_MISC_INIT_R
#define CONFIG_BOOTLOADER_BASE 0x01400000
#define CONFIG_SYS_CLK_FREQ 27000000
#define CFG_TIMERBASE 0x00030080

/*
 * Neuros DM320 OSD production hardware
 */

/*
 * General Configuration
 */

/*
 * Miscellaneous Processing Setup
 */
#undef CONFIG_USE_IRQ
#undef CFG_CLKS_IN_HZ
#define CONFIG_CMDLINE_TAG 1
#define CONFIG_INITRD_TAG 1
#define CONFIG_SETUP_MEMORY_TAGS 1

/*
 * Environment Configuration
 */
#define CFG_ENV_IS_IN_FLASH 1
#undef CFG_ENV_IS_IN_NVRAM
#undef CFG_ENV_IS_IN_EEPROM
#define CFG_ENV_OFFSET 0x00040000
#define CFG_ENV_SIZE 0x00020000
#define CFG_LONGHELP 1
#define CFG_PROMPT "Neuros Devboard >  "
#define CFG_CONSOLE_IS_IN_ENV 1
#undef CFG_CONSOLE_INFO_QUIET
#define CONFIG_ENV_OVERWRITE 1

/*
 * Environment Variable Configuration
 */
#define CONFIG_BOOTDELAY 3
#define CONFIG_BOOTARGS ""
#define CONFIG_BOOTFILE ""
#define CFG_LOAD_ADDR 0x01800000

/*
 * Network Variables
 */
#define CONFIG_HOSTNAME "neuros"
#define CONFIG_ETHADDR "80:4C:EF:54:87:0A"
#define CONFIG_SERVERIP "192.168.1.1"
#define CONFIG_IPADDR "192.168.1.100"
#define CONFIG_NETMASK "255.0.0.0"
#define CONFIG_GATEWAYIP "192.168.1.1"
#define CONFIG_DNSIP "192.168.1.1"

/*
 * Buffers/Stack Configuration
 */
#define CFG_MAXARGS 16
#define CFG_CBSIZE 256
#define CONFIG_STACKSIZE 0x00020000

/*
 * Character Devices
 */

/*
 * Serial Drivers
 */
#define CONFIG_DM320_UART 1
#define CFG_DM320_UART_BASE 0x00030300
#define CONFIG_BAUDRATE 115200

/*
 * Network Configuration
 */
#define CONFIG_NETWORK 1
#undef CONFIG_DRIVER_SMC91111
#undef CONFIG_DRIVER_SMC9118
#undef CONFIG_DRIVER_CS8900
#define CS8900_BUS16 1
#undef CS8900_BUS32
#define CONFIG_DRIVER_DM9000 1
#define CONFIG_DM9000_BASE 0x60000300
#undef CONFIG_DM9000_USE_8BIT
#define CONFIG_DM9000_USE_16BIT 1
#undef CONFIG_DM9000_USE_32BIT


#endif

  • If you have problems with linking (see error below), then follow this part on how to fix it.

Otherwise you're done.

-Even after this, when I built - it had problems with linking.

nw-audio-recorder.o: In function `OnMemTimer':
./../src/ui/nw-audio-recorder.c:343: undefined reference to `StorageSearch'
nw-audio-recorder.o: In function `AudioRecorderStart':
./../src/ui/nw-audio-recorder.c:657: undefined reference to `StorageSearch'
nw-video-recorder.o: In function `OnMemTimer':
./../src/ui/nw-video-recorder.c:443: undefined reference to `StorageSearch'
nw-video-recorder.o: In function `VideoRecorderStart':
./../src/ui/nw-video-recorder.c:812: undefined reference to `StorageSearch'
nw-set-video-recorder.o: In function `OnFlboxKeydown':
./../src/ui/nw-set-video-recorder.c:863: undefined reference to `FileListboxGetEntCount'
./../src/ui/nw-set-video-recorder.c:864: undefined reference to `FileListboxGetFullName'
nw-set-video-recorder.o: In function `CreateFormSetVideoRecorder':
./../src/ui/nw-set-video-recorder.c:913: undefined reference to `FileListboxNew'
./../src/ui/nw-set-video-recorder.c:914: undefined reference to `FileListboxSetCallback'
nw-set-audio-recorder.o: In function `OnFlboxKeydown':
./../src/ui/nw-set-audio-recorder.c:625: undefined reference to `FileListboxGetEntCount'
./../src/ui/nw-set-audio-recorder.c:626: undefined reference to `FileListboxGetFullName'
nw-set-audio-recorder.o: In function `CreateFormSetAudioRecorder':
./../src/ui/nw-set-audio-recorder.c:674: undefined reference to `FileListboxNew'
./../src/ui/nw-set-audio-recorder.c:675: undefined reference to `FileListboxSetCallback'
collect2: ld returned 1 exit status
make: *** [osdmain] Error 1

Nerochiaro helped me out on the solution for this. Apparently Neuros-Cooler does something to the library that causes problems when the linker tries to link against it. The fix is easy:

cp Neuros-Cooler/build/libncooler.so /lib strip /lib/libncooler.so

Then rebuild and it'll work. However, MakeNeurosCooler script copies the file for you already.

Personal tools