Upload
others
View
10
Download
0
Embed Size (px)
Citation preview
iCon User Manual (R2.0)
Revised June 2014 Page | 1
Features • 32-bit ARM Cortex-M3/M4 MCU, maximum frequency
up to 120MHz • 32M byte external Flash memory • 64M byte external SDRAM • 802.11b/g/n Wi-Fi • Bluetooth 4.0 • 1 x USB 2.0 full-speed • 1 x CAN 2.0B • 1 x RS485 • 1 x Console port (micro USB) • RTC with backup battery • Expansion I/O
o 16-bit RGB LCD o 10/100 Ethernet RMII o 2 x I2C o 2 x SPI o 1 x UART o 4 x PWM o 10 x GPIO o 3 x ADC o 1 x DAC
• uClinux operating system, kernel version 2.6.33-ARM1 • Open source TCP/IP, WPA supplicant, BlueZ stacks • Boa web server, Inadyn DDNS client included
Applications •
iCon User Manual (R2.0)
Revised June 2014 Page | 2
iCon, which stands for Internet Connectivity, is a low power embedded system designed for wireless Internet of Things (IoT) applications. A block diagram of the iCon is shown in Figure 1. At the heart of the iCon is a NXP LPC1788/LPC4088 microcontroller. The core operating frequency as well as the external memory bus frequency is optimized to 120MHz. There are two separated wireless modules installed on each iCon. The Bluetooth 4.0 module supports both Bluetooth classic mode and low energy master mode. The Wi-Fi module supports IEEE 802.11b/g/n with data rate achieved 72Mbps. Both wireless modules are fully CE, FCC, and Industry Canada qualified.
Furthermore, a standard USB 2.0 Type-A connector is provided. The default setting of this USB port is a full-speed USB host which allows a device such as a flash drive or USB-to-Ethernet adaptor to be connected. There is an 8-pin terminal block next to the USB connector. This terminal block is for connection to a +5V (maximum 2A) main power source, a CAN bus device, and a RS485 device with wires range from 20-26AWG. The pin assignment of the terminal block is shown in Figure 2.
Figure 1 – General block diagram
LPC1788LPC4088
32MBFlash
64MBSDRAM
802.11b/g/n
Bluetooth
RS485Driver
CANDriver
TerminalBlock
USB2.0
ResetSwitch
ISPSwitch
2x Expansion Connector
JTAGHeader
Console(USB)
UARTto USB
PowerRegulator
USB
SDIO
USB
CAN
UART
I/O
MEM
UART
iCon User Manual (R2.0)
Revised June 2014 Page | 3
Figure 2 – Terminal block pin assignment
In addition, a console port is provided through a Type-B mini USB connector (J11). Since the power through the mini USB connector is NOT connected to the on-board power regulator, the console port cannot be used to power the iCon.
Expansion Connectors Two expansion connectors (J8, J9) are located on the bottom side of the iCon. Both connectors are 2x20 pins, 2.0mm pitch. The factory default configurations of these connectors are shown in Figure 3. These configurations are set to provide users with a wide variety of interfaces. Note that other than the +5V, GND, RESET_OUT#, and the three Reserved pins, all pins are user programmable if needed. The +5V and GND are shared between the iCon and the expansion board. Thus it is possible to power the iCon through J8.
+5VGround
CANHCANL
Ground
Ground
RS485ARS485B
iCon User Manual (R2.0)
Revised June 2014 Page | 4
J8
J9 Signal Pin# Pin# Signal Signal Pin# Pin# Signal
I2C0_SDA 1 2 RMII_TXD0 LCD_VD3 1 2 TS_IRQ# I2C0_SCL 3 4 RMII_TXD1 LCD_VD4 3 4 LCD_HSYNC I2C1_SDA 5 6 RMII_TXEN LCD_VD5 5 6 LCD_VSYNC I2C1_SCL 7 8 RMII_RXD0 LCD_VD6 7 8 LCD_DE Reserved 9 10 RMII_RXD1 LCD_VD7 9 10 LCE_PWR_EN Reserved 11 12 RMII_RX_ER GND 11 12 LCD_DCLK SPI0_SCK 13 14 RMII_CLK LCD_VD10 13 14 GND SPI0_SSEL 15 16 RMII_CRS LCD_VD11 15 16 GPIO0
SPIO_MISO 17 18 RMII_MDIO LCD_VD12 17 18 GPIO1 SPIO_MOSI 19 20 RMII_MDC LCD_VD13 19 20 GPIO2 SPI1_SCK 21 22 PWM_OUT0 LCD_VD14 21 22 GPIO3 SPI1_SSEL 23 24 PWM_OUT1 LCD_VD15 23 24 GPIO4 SPI1_MISO 25 26 PWM_OUT2 GND 25 26 GPIO5 SPI1_MOSI 27 28 PWM_OUT3 LCD_VD19 27 28 GPIO6 UART3_TXD 29 30 RESET_OUT# LCD_VD20 29 30 GND UART3_RXD 31 32 GPIO7 LCD_VD21 31 32 ADC0
GPIO9 33 34 GPIO8 LCD_VD22 33 34 ADC1 GND 35 36 +5V LCD_VD23 35 36 ADC2 GND 37 38 +5V GND 37 38 DAC_OUT GND 39 40 +5V Reserved 39 40 GND
Figure 3 – Expansion connector pin assignment
Expansion Board Figure 4 shows the expansion connector and mounting hole locations on a typical expansion board. The two expansion connectors on the iCon are the MFS201-A06 from Jing Lai Electronics. The corresponding mating connector is the FFS201-A02.
iCon User Manual (R2.0)
Revised June 2014 Page | 5
Figure 4 – Expansion connector and mounting hole locations (as seen on the expansion board)
iCon User Manual (R2.0)
Revised June 2014 Page | 6
Figure 5 – 2x20 pins expansion connector (MFS201-A06)
iCon User Manual (R2.0)
Revised June 2014 Page | 7
Figure 6 – Mating connector (FFS201-A02) on expansion board
First Install Before starting building the kernel, be sure you have the basic dependencies to build the image. sudo apt-get install u-boot-tools If the arm-uclinuxeabi-gcc cannot be executed it is likely that the 32bit C libraries haven't been installed. The following command will install the sudo apt-get update sudo apt-get upgrade sudo apt-get install libc6-i386
iCon User Manual (R2.0)
Revised June 2014 Page | 8
Quick Install Download the arm-2010q1-189-arm-uclinuxeabi-i686-pc-linux-gnu.tar.bz2 compiler from the website and extract it to the /linux-cortexm-1.12.0/tools directory **Important Note** If you are using the CORTEX-M4
download the arm-amptek-uclinux-uclibcgnueabi.tar.bz2 compiler as well and extract it to the /linux-cortexm-1.12.0/tools directory. Be sure to uncomment the compiler in the ACTIVATE.sh script located in the /linux-cortexm-1.12.0 directory.
Modify networking.kernel.LPC file under projects/networking folder to enable the following cortex-m4 specific defines:
CONFIG_CORTEX_M4_SUPPORT=y You can do this by either manually editing the file or using the kernel interface by typing the following command under the projects/networking folder
make kmenuconfig Once the kernel configuration interface appears, navigate to the LCD settings and enable the display you are using: System Type LPC178x/7x I/O interfaces [*]Enable CORTEX-M4 pins Navigate to the /linux-cortexm-1.12.0/A2F/uclibc folder. Replace the kernel header path with yours located in the icon_config file. KERNEL_HEADERS="/path/to/your/linux-cortexm-1.12.0/linux/usr/include" Using a terminal naviagate to the /linux-cortexm-1.12.0 directory and run the following commands. . ACTIVATE.sh ./first_build **Note** If first build is not building properly, you could be missing some basic dependencies. Follow the manual install to see where the build goes wrong.
Manual Install Step 1: Export Compiler Paths
iCon User Manual (R2.0)
Revised June 2014 Page | 9
Download the arm-2010q1-189-arm-uclinuxeabi-i686-pc-linux-gnu.tar.bz2 compiler from the website and extract it to the /linux-cortexm-1.12.0/tools directory **Important Note** If you are using the CORTEX-M4
download the arm-amptek-uclinux-uclibcgnueabi.tar.bz2 compiler as well and extract it to the /linux-cortexm-1.12.0/tools directory. Be sure to uncomment the compiler in the ACTIVATE.sh script located in the /linux-cortexm-1.12.0 directory.
Modify networking.kernel.LPC file under projects/networking folder to enable the following cortex-m4 specific defines:
CONFIG_CORTEX_M4_SUPPORT=y You can do this by either manually editing the file or using the kernel interface by typing the following command under the projects/networking folder
make kmenuconfig Once the kernel configuration interface appears, navigate to the LCD settings and enable the display you are using: System Type LPC178x/7x I/O interfaces [*]Enable CORTEX-M4 pins Using the terminal navigate to the /linux-cortexm-1.12.0 directory and run the ACTIVATE.sh file. /Documents/linux-cortexm-1.12.0$ . ACTIVATE.sh Step 2: Build the Kernel Once done, navigate to the /linux-cortexm-1.12.0/projects/networking directory and enter the following commands. make clean make Step 3: Replace networking.initramfs Once the kernel is build without any errors replace the networking.initramfs file with the bp_networking.initramfs. You can use the following commands for it. rm networking.initramfs cp bp_networking.initramfs networking.initramfs
iCon User Manual (R2.0)
Revised June 2014 Page | 10
*Note this is needed only for the first build* Step 3: Build All libraries Navigate to the /linux-cortexm-1.12.0/A2F/uclibc Folder. Replace the kernel header path with yours located in the icon_config file. KERNEL_HEADERS="/path/to/your/linux-cortexm-1.12.0/linux/usr/include" Go to the /linux-cortexm-1.12.0/A2F Folder and run the clean script. . clean.sh Once the clean is done, build the libraries with the following script. . build.sh Lastly build the Wifi driver . wifi_driver.sh Step 4: Rebuild the kernel with make. Repeating step 2 WITHOUT a "make clean" Step 5: Done! You can now copy the networking.uImage onto the icon board.
Viewing ICON board through Tera Term Tera Term is just one example of viewing the kernel of the iCon board. The tool is free and can be downloaded from http://ttssh2.sourceforge.jp. One may use any other serial console.
Tera Term Setup Step 1:
Open Tera Term and select the correct port that is attached to the board. File -> New connection
iCon User Manual (R2.0)
Revised June 2014 Page | 11
*Note* You can check the port under Device manager in windows. *Note* If you have other programs accessing the port such as TFTP terminal or Flash Magic you must close them down first.
Adjust the Baud rate to 115200 Step 2:
Setup -> Serial port
iCon User Manual (R2.0)
Revised June 2014 Page | 12
Press OK
iCon User Manual (R2.0)
Revised June 2014 Page | 13
Creating a u-boot image Step 1: Using a terminal, navigate to the u-boot directory and clean the build before starting with the following commands:
make clean make distclean
Step 2: If building for the cortex-m3 board use the following command:
make ea-lpc1788_config If building for the cortex-m4 board use the following command:
make ea-lpc4088_config Step 3: Finally build the u-boot.hex image which you will use to flash the board.
make u-boot.hex
Flashing U-boot Flash Magic is needed to complete this task. Flash Magic is a free tool and can be downloaded from http://www.flashmagictool.com.
YOU CAN SKIP (STEP 1) IF THIS IS NOT A FIRST TIME FLASH. Step 1:
Boot up the board and view the terminal through Tera Term (See Above). Hit the reset button on the icon board and hit any key to stop the boot-up .
iCon User Manual (R2.0)
Revised June 2014 Page | 14
Type in the terminal the following commands -Protect off all - erase all
iCon User Manual (R2.0)
Revised June 2014 Page | 15
Step 2 :
Plug in the power and put the board into ISP mode. You can put the board into ISP Mode by holding down SW2, and then hold down the reset button for about 2 seconds. Release the reset button and then release SW2.
Once in ISP mode, open Flash Magic. Below should be the settings you will need. Step 3:
Make sure: • Directory to the u-boot.hex is correct • COM Port to the board is correct
When everything is correct hit the “Start” button.
Once it is finished close Flash Magic, open Tera Term and then reboot the iCon board to view the u-boot.
Step 4:
iCon User Manual (R2.0)
Revised June 2014 Page | 16
Flashing External Memory (NOR FLASH)
Restart the iCon board and hit enter in Tera Term. Step 1:
Type “printenv” to bring up the environment variables so you can check the BOARD IP and SERVER IP. There are 3 different ways one can flash the NOR flash. They are listed from fastest to slowest based on programming speed.
Method 1: TFTP Ethernet programming
Create a TFTP server on the host computer which is where you will put the generated uImage from the project . (See Building uImage).
Before programming the NOR flash, make sure that the Image name of the generate uImage is the same name as the environmental variable in the u-boot. Also make sure that the host computer IP and board IP is correct. To see the environmental variables type: printenv .
See the below figure.
iCon User Manual (R2.0)
Revised June 2014 Page | 17
If you have to change any of the environmental variables
iCon User Manual (R2.0)
Revised June 2014 Page | 18
setenv {name of variable} {new value} - set the variable saveen - save the variable
See below figure for example:
Once everything is set properly, type in the console “run update” to flash the NOR FLASH
.
iCon User Manual (R2.0)
Revised June 2014 Page | 19
Method 2: USB programming There are two usb methods to flash the NOR. One requires an image with usb support already flashed in the NOR flash and the other one does not.
PART1: No image in NOR flash Download the uimage by typing in the terminal :
loadb ${loadaddr}
Below is what you should see.
Now in the Tera Term menubar. Select File Transfer Kermit Send
Step 6:
Choose your uImage file. In this example we are using “network.uImage”.
The file should be downloading. Wait for it to finish.
Once the file is finished downloading , type in the following commands.
Step 7:
prot off ${flashaddr} +${filesize};
iCon User Manual (R2.0)
Revised June 2014 Page | 20
era ${flashaddr} +${filesize};
cp.b ${loadaddr} ${flashaddr} ${filesize}
Below is what you should see:
Type in “reset” and the kernel should reboot and start.
PART2: Pre flashed Image that supports USB booting the kernel
Download the uImage to a USB flash drive.
Step 1
Reboot the iCon board
Step 2
Once the kernel is up and running, run the following commands.
Step 3
flash_eraseall -j /dev/mtd2
iCon User Manual (R2.0)
Revised June 2014 Page | 21
mkdir /mnt
mount -t jffs2 /dev/mtdblock2 /mnt
Plug in the USB flash drive with the image
Step 4
mount -t vfat /dev/sda1 /mnt
*Note* On step 4 the command may be different for the location of the USB. Most likely when you plug in the usb it will say “sda1”. If it says something else like sdc1 or sdb1 please replace sda1 with that.
Erase the existing image
Step 5
flash_eraseall /dev/mtd1
flashcp /mnt/networking.uImage /dev/mtd1
reboot
If everything goes right, you should have a new image.
Quick Guide to known usages.
Using GPIOS
Declaring Board GPIOS Linux/arch/arm/mach-lpc178x/iomux.c are the declaration of the board GPIOS. If a gpio is not working. In most cases this is because either a) the gpio is being used by another resource or it is not defined in this file, which you can.
Controlling Board GPIOS
Gpio’s in the kernel console can be found under /sys/class/gpio
iCon User Manual (R2.0)
Revised June 2014 Page | 22
/sys/class/gpio # ls export gpiochip0 unexport
Exporting New GPIOS GPIO numbering is calculated with the following formula ( gpio# = 32 * PORT + PIN) . See LPC1788 manual chart of PORTS and their PIN functionality.
ex. exporting gpio 0.
/sys/class/gpio # echo 0 > export
Setting New Direction
/sys/class/gpio # echo in > gpio0/direction /sys/class/gpio # cat gpio0/direction /sys/class/gpio #
Setting New Value
/sys/class/gpio # echo 0 > gpio0/value /sys/class/gpio # cat gpio0/value 0
Connecting to a WPA Network If this is the first time running the Network script, remove the /mnt/etc folder and /mnt/tmp folders. You can do this by using the following command:
rm –r /mnt/etc rm –r /mnt/tmp
Run the automated network script to connect to a network. The script is located in the /etc folder. ./Network_Config
Starting up Bluetooth hcid -n &
hciconfig hci0 auth up
If for example you want to try to connect from your phone, it will ask for the password. The default password is 1234.
You may change this in the /etc/pin and /usr/bin/bluepin. See “Compiling a New uImage” to permanently change the pin number.
iCon User Manual (R2.0)
Revised June 2014 Page | 23
Starting up Boa Webserver
boa &
Mounting USB Make sure to mount the correct drive.
mount -t vfat /dev/sda1 /mnt
*Note when you insert your usb stick may mount on sda or sdb.
Storing Persistant files flash_eraseall -j /dev/mtd2
*Note you do not to erase the flash every single time you mount the jffs2 filesytem
mkdir /storage
mount -t jffs2 /dev/mtdblock2 /storage
You may store files in the /storage now that will remain in memory even after powering down.
Controlling CAN Device
Start up the can device *Note* Currently the bitrate is static. It must be changed in the /linux/arch/arm/mach-lpc178x/can.c file.
ip link set can0 type can bitrate 500000 ifconfig can0 up
Receiving CAN inputs. candump can0 –o > logfile.txt &
Sending CAN data. cansend can0 –i 0x123 0xaa 0xbb 0xcc 0xdd
Compiling Basic C programs
iCon User Manual (R2.0)
Revised June 2014 Page | 24
Download GNU Cross build tools for the Cortex-M3 from:
http://www.amptek-tech.com/iCon-M3.html
Download GNU Cross build tools for the Cortex-M4 from:
http://www.amptek-tech.com/iCon-M4.html
Make sure to specify the path to the compiler when compiling your c programs. Also make sure to include
The Compiler flags as well as the Library flags that you use.
Cortex-m3 Example:
Compiling a Simple "Hello world" c program.
arm-uclinuxeabi-gcc -Os -mcpu=cortex-m3 -mthumb hello_world.c -o hello_world
Cortex-m4 Example:
Compiling a Simple "Hello world" c program.
arm-amptek-uclinux-uclibcgnueabi-gcc -Os -mcpu=cortex-m3 -mthumb hello_world.c -o hello_world
**Note 1 ** the cortex-m4 compiler is experimental and contains minimal usages. It’s recommend that if you are not compiling for hard floating point to use the cortex-m3 compiler*
LCD
Configuring LCD Sizes In a terminal navigate to the /projects/networking folder.
make kmenuconfig Once the kernel configuration interface appears, navigate to the LCD settings and enable the display you are using: Sytem Type LPC178x/7x I/O interfaces [*]Enable LCD 4.3 inch [ ]Enable LCD 7 inch
iCon User Manual (R2.0)
Revised June 2014 Page | 25
Compiling a New UIMAGE
*Note* It is recommended but not mandatory to “make clean” before compiling the kernel. This way one can avoid unnecessary compile errors or corrupted files.
INITRAMFS Located in the / linux-cortexm-1.11.0/project/networking folder. This file contains all the symobolic links to the busybox as well as library’s. Any new library or busybox commands should be added to this file.
Recompiling a New Wifi Module *Note if any changes to kernel are done you must recompile the wifi driver* Under the /A2F folder run the following command . wifi_driver.sh
Recompiling a bluetooth driver Under the /A2F folder run the following command . build_bluetooth.sh
Recompiling a uclibc driver Under the /A2F folder run the following command cd uclibc make clean make distclean cp icon_config .config make ARCH_CFLAGS= 'CPU_CFLAGS=-mthumb -march=armv7 -mfix-cortex-m3-ldrd' -j2 -s make ARCH_CFLAGS= 'CPU_CFLAGS=-mthumb -march=armv7 -mfix-cortex-m3-ldrd' -s PREFIX=$INSTALL_ROOT/A2F/uclibc_output install