Mcu software on Andes platform Andes Technology


Download 445 b.
Sana08.07.2018
Hajmi445 b.


MCU software on Andes platform

  • Andes Technology


Outline



The Purpose of This Training Class

  • Teach All the skills relating Andes software developing

  • Maybe you are not familiar with Andes developing tools. But you can programming everything if you want to learn.



Andes bootstrap

  • Purpose

    • Device lowlevel Initial
    • Link to main program
  • Content

    • Setup vectors
    • Reset
    • Lowlevel_init
    • Relocate
    • Copy_loop
    • Remap
    • Clear bss
    • Setup stack
    • Jump to main program
  • Linker script



Bootstrap Source Code Study

  • ********************************************************************************************************

  • ! uC/OS-II

  • ! The Real-Time Kernel

  • !

  • ! (c) Copyright 2005-2007, Andes Techonology

  • ! All Rights Reserved

  • !

  • ! NDS32 Generic Port

  • ! GNU C Compiler

  • !

  • ! File : OS_CPU_A.ASM

  • ! Version : V1.50

  • ! By : Swee Tseng @ Andes Technology

  • !

  • !********************************************************************************************************

  • !********************************************************************************************************

  • ! INCLUDE ASSEMBLY CONSTANTS

  • !********************************************************************************************************

  • #include "n12_def.h"

  • !********************************************************************************************************

  • ! IMPORT and EXPORT

  • !********************************************************************************************************

  • ! IMPORT OSRunning

  • ! IMPORT OSPrioCur

  • ! IMPORT OSPrioHighRdy

  • ! IMPORT OSTCBCur

  • ! IMPORT OSTCBHighRdy

  • ! IMPORT OSIntNesting

  • ! IMPORT OSIntExit

  • ! IMPORT OSTaskSwHook

  • ! IMPORT OS_CPU_IRQ_ISR_Handler

  • ! IMPORT BSP_Init

  • ! IMPORT APP_Init

  • ! IMPORT _edata

  • ! IMPORT _end

  • .global _start

  • .global OSStartHighRdy

  • .global OSCtxSw

  • .global OSIntCtxSw

  • .global OS_Init_Nds32

  • .global OS_Int_Vectors

  • .global OS_Int_Vectors_End

  • /* pre-define */

  • .equ DEBUG, 0

  • .equ ANDES_PLATFORM, 1

  • .equ SYSTEM_INIT, 1

  • ! Switch to interruption level \lv

  • .macro IntlSwitch lv

  • mfsr $a0, $PSW

  • li $a1, #~PSW_mskINTL

  • and $a0, $a0, $a1

  • ori $a0, $a0, #(\lv << PSW_offINTL)

  • mtsr $a0, $PSW

  • isb

  • .endm

  • ! Save current task's context

  • .macro CtxSave

  • #ifdef NDS32_REDUCE_REGS

  • pushm $r28, $r30

  • pushm $r15, $r15

  • pushm $r0, $r10

  • #else

  • pushm $r0, $r30

  • #endif

  • mfusr $a5, $d0.hi ! get d0.hi

  • mfusr $a4, $d0.lo ! get d0.lo

  • mfusr $a3, $d1.hi ! get d1.hi

  • mfusr $a2, $d1.lo ! get d1.lo

  • mfsr $a1, $IPC ! get return address

  • mfsr $a0, $IPSW ! get IPSW

  • pushm $a0, $a5

  • move $a0, $sp

  • andi $a1, $sp, #7

  • bnez $a1, 1f

  • push $a0

  • 1:

  • push $a0

  • .endm

  • ! Restore to new task's context

  • .macro CtxRestore

  • pop $a0

  • move $sp, $a0

  • popm $a0, $a5

  • mtsr $a0, $IPSW

  • mtsr $a1, $IPC

  • mtusr $a2, $d1.lo

  • mtusr $a3, $d1.hi

  • mtusr $a4, $d0.lo

  • mtusr $a5, $d0.hi

  • #ifdef NDS32_REDUCE_REGS

  • popm $r0, $r10

  • popm $r15, $r15

  • popm $r28, $r30

  • #else

  • popm $r0, $r30

  • #endif

  • .endm

  • .macro CallFn fn

  • addi $sp, $sp, #-24 ! reserve 6 words accroding to ABI

  • bal \fn

  • addi $sp, $sp, #24

  • .endm

  • !********************************************************************************************************

  • ! Entry and initialization

  • !********************************************************************************************************

  • .section .init, "ax"

  • _start:

  • j OS_Init_Nds32

  • .section .text

  • ! Define standard NDS32 vector table entry point of interruption vectors

  • .macro VECTOR handler

  • .align 4

  • push $a0

  • sethi $a0, hi20(\handler)

  • ori $a0, $a0, lo12(\handler)

  • jral $a0, $a0

  • .endm

  • OS_Int_Vectors:

  • VECTOR OS_Init_Nds32 ! (0) Trap Reset/NMI

  • VECTOR OS_Trap_TLB_Fill ! (1) Trap TLB fill

  • VECTOR OS_Trap_PTE_Not_Present ! (2) Trap PTE not present

  • VECTOR OS_Trap_TLB_Misc ! (3) Trap TLB misc

  • VECTOR OS_Trap_TLB_VLPT_Miss ! (4) Trap TLB VLPT miss

  • VECTOR OS_Trap_Machine_Error ! (5) Trap Machine error

  • VECTOR OS_Trap_Debug_Related ! (6) Trap Debug related

  • VECTOR OS_Trap_General_Exception ! (7) Trap General exception

  • VECTOR OS_Trap_Syscall ! (8) Syscall

  • VECTOR OS_Trap_Interrupt_HW0 ! (9) Interrupt HW0

  • VECTOR OS_Trap_Interrupt_HW1 ! (10) Interrupt HW1

  • VECTOR OS_Trap_Interrupt_HW2 ! (11) Interrupt HW2

  • VECTOR OS_Trap_Interrupt_HW3 ! (12) Interrupt HW3

  • VECTOR OS_Trap_Interrupt_HW4 ! (13) Interrupt HW4

  • VECTOR OS_Trap_Interrupt_HW5 ! (14) Interrupt HW5

  • VECTOR OS_SWI ! (15) Interrupt SW0

  • OS_Int_Vectors_End:

  • ! Redirect unhandled exceptions / interrupts

  • OS_Trap_TLB_Fill:

  • li $a0, 0x01

  • b OS_Exception

  • OS_Trap_PTE_Not_Present:

  • li $a0, 0x02

  • b OS_Exception

  • OS_Trap_TLB_Misc:

  • li $a0, 0x03

  • b OS_Exception

  • OS_Trap_TLB_VLPT_Miss:

  • li $a0, 0x04

  • b OS_Exception

  • OS_Trap_Machine_Error:

  • li $a0, 0x05

  • b OS_Exception

  • OS_Trap_Debug_Related:

  • li $a0, 0x06

  • b OS_Exception

  • OS_Exception:

  • li $a1, 0x902ffffc

  • swi $a0, [$a1]

  • b OS_Exception

  • OS_Trap_Syscall:

  • li $a0, 0x07

  • b OS_Unused

  • OS_Trap_Interrupt_HW0:

  • li $a0, 0x08

  • b OS_Unused

  • OS_Trap_Interrupt_HW2:

  • li $a0, 0x09

  • b OS_Unused

  • OS_Trap_Interrupt_HW3:

  • li $a0, 0x0A

  • b OS_Unused

  • OS_Trap_Interrupt_HW4:

  • li $a0, 0x0B

  • b OS_Unused

  • OS_Trap_Interrupt_HW5:

  • li $a0, 0x0C

  • b OS_Unused

  • OS_SWI:

  • li $a0, 0x0D

  • b OS_Unused

  • OS_Unused:

  • li $a1, 0x902ffffc

  • swi $a0, [$a1]

  • b OS_Unused

  • OS_Trap_General_Exception:

  • push $a1

  • li $a0, 0x0E

  • li $a1, 0x902ffffc

  • swi $a0, [$a1]

  • die:

  • b die

  • mfsr $a0, $IPC

  • addi $a0, $a0, #4

  • mtsr $a0, $IPC

  • pop $a1

  • pop $a0

  • CtxSave

  • ! CallFn tm_interrupt_handler

  • ! CallFn tm_interrupt_preemption_handler

  • CtxRestore

  • iret

  • !********************************************************************************************************

  • ! OS_Init_Nds32

  • !

  • ! Note(s) : 1) OS_Init_Nds32 init SP pointer, cache,

  • !

  • !********************************************************************************************************

  • .align 2

  • OS_Init_Nds32:

  • /* reset */

  • .if ANDES_PLATFORM

  • li $r0, 0x98700004

  • lwi $r1, [$r0]

  • srli $r2, $r1, #1

  • andi $r2, $r2, #0x1

  • bnez $r2, NormalBoot

  • li $r0, 0x90200000 ! 32-bit boot

  • li $r1, 0x10000052

  • li $r2, 0x00151151

  • swi $r1, [$r0+#0x00]

  • swi $r2, [$r0+#0x04]

  • li $r1, #0x200000

  • la $r0, _text

  • addi $r0, $r0, #0x5ec

  • add $r0, $r0, $r1

  • jr $r0

  • .endif ! end ANDES_PLATFORM

  • NormalBoot:

  • .if DEBUG

  • move $r7, #0x10

  • bal show_80

  • .endif

  • ! Processor should be in Super User mode

  • ! Disable interrupts, change to interruption level 0

  • mfsr $a0, $PSW

  • li $a1, #~PSW_MSK

  • and $a0, $a0, $a1

  • li $a1, #PSW_INIT

  • or $a0, $a0, $a1

  • mtsr $a0, $PSW

  • isb

  • .if DEBUG

  • move $r7, #0x11

  • bal show_80

  • .endif

  • mfsr $a0, $INT_MASK

  • li $a1, #~INT_MASK_MSK

  • and $a0, $a0, $a1

  • li $a1, #INT_MASK_INIT

  • or $a0, $a0, $a1

  • mtsr $a0, $INT_MASK

  • mfsr $a0, $IVB

  • li $a1, #~IVB_MSK

  • and $a0, $a0, $a1

  • li $a1, #IVB_INIT

  • or $a0, $a0, $a1

  • mtsr $a0, $IVB

  • mfsr $a0, $MMU_CTL

  • li $a1, #~MMU_CTL_MSK

  • and $a0, $a0, $a1

  • li $a1, #MMU_CTL_INIT

  • or $a0, $a0, $a1

  • mtsr $a0, $MMU_CTL

  • mfsr $a0, $CACHE_CTL

  • li $a1, #~CACHE_CTL_MSK

  • and $a0, $a0, $a1

  • li $a0, #CACHE_CTL_INIT

  • mtsr $a0, $CACHE_CTL

  • .if SYSTEM_INIT

  • bal lowlevel_init

  • /* relocate */

  • #! relocate:

  • .if DEBUG

  • move $r7, #0x14

  • bal show_80

  • .endif

  • #! copy ROM code to SDRAM(current is at 0x10000000) and verify

  • li $r4, #0x10000000 ! 0x10000000 DRAM HIGH memory

  • la $r5, _text

  • la $r6, __bss_start

  • /* copy_loop */

  • 17: !copy_loop

  • .if DEBUG

  • move $r7, #0x15

  • bal show_80

  • .endif

  • lwi $r7, [$r5]

  • swi $r7, [$r4]

  • lwi $r7, [$r5]

  • lwi $r8, [$r4]

  • bne $r7, $r8, die !SDRAM_ERROR

  • addi $r5, $r5, #4

  • addi $r4, $r4, #4

  • blt $r5, $r6, 17b

  • bal remap

  • .endif ! end of SYSTEM_INIT

  • ! Clear bss

  • la $a0, _edata

  • la $a1, _end

  • li $a2, #0

  • 1:

  • sub $a3, $a0, $a1

  • bgez $a3, 2f

  • swi.bi $a2, [$a0], #4

  • b 1b

  • 2:

  • .if DEBUG

  • move $r7, #0x12

  • bal show_80

  • .endif

  • ! Set-up the stack pointer

  • la $sp, __OS_Sys_Stack

  • #if (defined(CONFIG_CPU_ICACHE_ENABLE) || defined(CONFIG_CPU_DCACHE_ENABLE))

  • mfsr $a0, $MMU_CTL

  • li $a1, #~MMU_CTL_MSK

  • and $a0, $a0, $a1

  • li $a1, #MMU_CTL_INIT_CACHE_ON

  • or $a0, $a0, $a1

  • mtsr $a0, $MMU_CTL

  • mfsr $a0, $CACHE_CTL

  • li $a1, #~CACHE_CTL_MSK

  • and $a0, $a0, $a1

  • li $a0, #CACHE_CTL_INIT

  • #ifdef CONFIG_CPU_ICACHE_ENABLE

  • CallFn n12_icache_flush;

  • li $a1, (0x1UL << CACHE_CTL_offIC_EN)

  • or $a0, $a0, $a1

  • #endif

  • #ifdef CONFIG_CPU_DCACHE_ENABLE

  • CallFn n12_dcache_invalidate;

  • li $a1, (0x1UL << CACHE_CTL_offDC_EN)

  • or $a0, $a0, $a1

  • #endif

  • .if DEBUG

  • move $r7, #0x13

  • bal show_80

  • .endif

  • mtsr $a0, $CACHE_CTL

  • #endif

  • .if DEBUG

  • move $r7, #0x18

  • bal show_80

  • .endif

  • ! Perform BSP initialization

  • CallFn BSP_Init

  • ! Call APP_Init(fisrt_available_memory), and never go back

  • la $a0, _end

  • CallFn APP_Init

  • ! Infinite loop, if returned from APP_Init accidently

  • 1:

  • b 1b

  • !********************************************************************************************************

  • ! START MULTITASKING

  • ! void OSStartHighRdy(void)

  • !

  • ! Note(s) : 1) OSStartHighRdy() MUST:

  • ! a) Call OSTaskSwHook() then,

  • ! b) Set OSRunning to TRUE,

  • ! c) Switch to the highest priority task.

  • !********************************************************************************************************

  • .text

  • .align 2

  • OSStartHighRdy:

  • #if OS_TASK_SW_HOOK_EN

  • CallFn OSTaskSwHook

  • #endif

  • li $a0, #1 ! OSRunning = TRUE

  • la $a1, OSRunning

  • sbi $a0, [$a1]

  • ! Switch to highest priority task

  • la $a0, OSTCBHighRdy ! Get highest priority task TCB->stack pointer

  • lwi $a1, [$a0]

  • lwi $sp, [$a1] ! Switch to the new stack

  • IntlSwitch #1 ! Switch to interruption level 1

  • CtxRestore ! Restore to origianl task's context

  • iret

  • !********************************************************************************************************

  • ! PERFORM A CONTEXT SWITCH (From task level) - OSCtxSw()

  • !

  • ! Note(s) : 1) OSCtxSw() is called in SYS mode with BOTH FIQ and IRQ interrupts DISABLED

  • !

  • ! 2) The pseudo-code for OSCtxSw() is:

  • ! a) Save the current task's context onto the current task's stack

  • ! b) OSTCBCur->OSTCBStkPtr = $SP

  • ! c) OSTaskSwHook()

  • ! d) OSPrioCur = OSPrioHighRdy

  • ! e) OSTCBCur = OSTCBHighRdy

  • ! f) $SP = OSTCBHighRdy->OSTCBStkPtr

  • ! g) Restore the new task's context from the new task's stack

  • ! h) Return to new task's code

  • !

  • ! 3) Upon entry:

  • ! OSTCBCur points to the OS_TCB of the task to suspend

  • ! OSTCBHighRdy points to the OS_TCB of the task to resume

  • !

  • !********************************************************************************************************

  • .text

  • .align 2

  • OSCtxSw:

  • mfsr $a0, $PSW

  • mtsr $a0, $IPSW

  • mtsr $lp, $IPC

  • CtxSave ! Save current task's context

  • la $a0, OSTCBCur ! OSTCBCur->OSTCBStkPtr = $SP

  • lwi $a1, [$a0]

  • swi $sp, [$a1]

  • ! Fall through for the rest of handling (step c -> h)

  • !********************************************************************************************************

  • ! PERFORM A CONTEXT SWITCH (From interrupt level) - OSIntCtxSw()

  • !

  • ! Note(s) : 1) OSIntCtxSw() is called in SYS mode with BOTH FIQ and IRQ interrupts DISABLED

  • !

  • ! 2) The pseudo-code for OSCtxSw() is:

  • ! a) OSTaskSwHook()

  • ! b) OSPrioCur = OSPrioHighRdy

  • ! c) OSTCBCur = OSTCBHighRdy

  • ! d) $SP = OSTCBHighRdy->OSTCBStkPtr

  • ! e) Restore the new task's context from the new task's stack

  • ! f) Return to new task's code

  • !

  • ! 3) Upon entry:

  • ! OSTCBCur points to the OS_TCB of the task to suspend

  • ! OSTCBHighRdy points to the OS_TCB of the task to resume

  • !********************************************************************************************************

  • OSIntCtxSw:

  • #if OS_TASK_SW_HOOK_EN

  • CallFn OSTaskSwHook

  • #endif

  • la $a0, OSPrioHighRdy ! OSPrioCur = OSPrioHighRdy

  • lbi $a1, [$a0]

  • la $a0, OSPrioCur

  • sbi $a1, [$a0]

  • la $a0, OSTCBHighRdy ! OSTCBCur = OSTCBHighRdy

  • lwi $a1, [$a0]

  • la $a0, OSTCBCur

  • swi $a1, [$a0]

  • lwi $sp, [$a1] ! $SP = OSTCBHighRdy->OSTCBStkPtr

  • IntlSwitch #1 ! Switch to interruption level 1

  • CtxRestore ! Restore to origianl task's context

  • iret

  • !********************************************************************************************************

  • ! IRQ Interrupt Service Routine

  • !********************************************************************************************************

  • .text

  • .align 2

  • OS_Trap_Interrupt_HW1:

  • xor $a0, $a0, $a0

  • #ifdef CONFIG_USING_PFM

  • mtsr $a0, $PFMC0

  • #else

  • push $ta

  • li $ta, #(0x98400000 + 0x10) /* Timer 2 counter */

  • swi $a0, [$ta + #0]

  • pop $ta

  • #endif

  • ! Check whether or not IRQ really happened

  • mfsr $a0, $INT_PEND

  • andi $a0, $a0, #INT_PEND_mskH1I

  • bnez $a0, 1f

  • pop $a0

  • iret

  • 1:

  • pop $a0

  • CtxSave ! Save current task's context

  • IntlSwitch #0 ! Switch to interrupt level 0

  • ! Handle nesting counter

  • la $a1, OSIntNesting ! if (OSIntNesting == 0) {

  • lbi $a0, [$a1]

  • bnez $a0, 2f

  • la $a0, OSTCBCur ! OSTCBCur->OSTCBStkPtr = $SP

  • lwi $a1, [$a0]

  • swi $sp, [$a1]

  • ! Switch to Interruption stack ! $SP = &__OS_Int_Stack

  • la $sp, __OS_Int_Stack ! }

  • 2:

  • CallFn OSIntEnter

  • CallFn OS_CPU_IRQ_ISR_Handler

  • CallFn OSIntExit

  • ! Check for non-nested interruption return

  • la $a0, OSIntNesting ! if (OSIntNesting == 0) {

  • lbi $a1, [$a0]

  • bnez $a1, 3f

  • la $a0, OSTCBCur ! $SP = OSTCBCur->OSTCBStkPtr

  • lwi $a1, [$a0]

  • lwi $sp, [$a1]

  • 3: ! }

  • IntlSwitch #1 ! Switch to interruption level 1

  • CtxRestore ! Restore to origianl task's context

  • iret

  • /* show led on leopard */

  • .global show_80

  • show_80:

  • li $r8, 0x902ffffc ! 0x902ffffc

  • swi $r7, [$r8]

  • ret

  • !********************************************************************************************************

  • ! POINTERS TO VARIABLES

  • !********************************************************************************************************

  • .data

  • .align 3

  • .skip IRQ_STACK_SIZE

  • __OS_Int_Stack:

  • .data

  • .align 3

  • .skip SYS_STACK_SIZE

  • __OS_Sys_Stack:

  • .end



Bootstrap Procedure Analysis



Boot Loader Linker Script

  • /* Linker script for AG101 diagnostic program */

  • OUTPUT_FORMAT("elf32-nds32", "elf32-nds32", "elf32-nds32")

  • OUTPUT_ARCH(nds32)

  • ENTRY(_start)

  • SECTIONS

  • {

  • . = 0x00000000;

  • . = ALIGN(4);

  • .text :

  • {

  • _text = .;

  • *(.init)

  • *(.text)

  • }

  • __data_start = .;

  • .data ALIGN(4) :

  • {

  • *(.data)

  • }

  • __data_end = .;

  • __sdata_start = .;

  • .sdata ALIGN(4) :

  • {

  • *(.sdata_w)

  • *(.sdata_h)

  • *(.sdata_b)

  • }

  • __sdata_end = .;

  • _edata = .;

  • PROVIDE(edata = .);

  • . = ALIGN(4);



DPF Architecture on μC/OS –II

  • Advantage of OS, particularly RTOS

  • μC/OS –II version 2.8.6



Andes boot code - EBIOS

  • Please press a GPIO Button for booting:

  • _________________________________________________________

  • GPIO1 (SW4): Run Setup & Diagnosis

  • GPIO2 (SW5): Burnin Test

  • _________________________________________________________

  • CPUID: 0x09040013 | COREID: 0 |

  • ------------------------------------------------------------------------------

  • Andes Development Platform Diagnosis Menu, Built@Sep 10 2008 (cheetah)

  • CPU: N9 Platform: ADP-XC5FF676 Cache: id-off CPU: 40MHz HCLK: 40MHz

  • ------------------------------------------------------------------------------

  • ( 1) SDRAM Test ( 2) Timer Test ( 3) DMA Test

  • ( 5) UART Loopback Test ( 6) UART DMA Test ( 9) Watchdog Test

  • (10) Watchdog Reset Test(11) MAC Loopback Test (12) Flash Test

  • (13) SODIMM Sizing (14) SDRAM(bnk1,2) (17) AC97 Test

  • (18) AC97 DMA Test (20) I2C Test (21) LCD Test

  • (22) LCD Menu (23) Query RTC (24) RTC Alarm Test

  • (25) GPIO Test (35) CF, SD Test (53) Enable Cache

  • (54) Disable Cache (55) CLI (67) Set Console's UART

  • (75) Burnin Test (76) Auto Burnin Test (78) Fully Auto Test

  • (79) Interactive Test (91) GO LINUX (95) Burn Image Main

  • (96) NDS BOOT (97) CopyImageFromCard (98) Exec_User_Programd

  • (99) Setup

  • Command>>



Lab : EBIOS <-> μC/OS –II

  • Compiler/build μC/OS –II demo program-without bootstrap

  • Download to EVB board DRAM

  • Execute μC/OS –II demo program

  • Compiler/build μC/OS –II demo program-with bootstrap

  • Replace EBIOS by μC/OS –II demo program

  • Burn back EBIOS through ICE



U-boot

  • serial_init> baudrate: 38400

  • U-Boot 1.2.0 (May 19 2009 - 01:32:00)

  • ANDES maintain version 0.16. Clock:83MHz

  • ANDESboot code: 00000000 -> 0002db1c

  • DRAM Configuration:

  • Bank #0: 00000000 0 KB

  • ID1:890089, ID2:180018

  • Find Intel flash

  • Flash: 32 MB

  • NDS32>help



U-boot command

  • NDS32>help

  • ? - alias for 'help'

  • autoscr - run script from memory

  • base - print or set address offset

  • bdinfo - print Board Info structure

  • boot - boot default, i.e., run 'bootcmd'

  • bootd - boot default, i.e., run 'bootcmd'

  • bootm - boot application image from memory

  • bootp - boot image via network using BootP/TFTP protocol

  • cmp - memory compare

  • coninfo - print console devices and information

  • cp - memory copy

  • crc32 - checksum calculation

  • echo - echo args to console

  • erase - erase FLASH memory

  • flinfo - print FLASH memory information

  • go - start application at address 'addr'

  • help - print online help

  • iminfo - print header information for application image

  • imls - list all images found in flash

  • itest - return true/false on integer compare

  • loadb - load binary file over serial line (kermit mode)

  • loads - load S-Record file over serial line

  • loady - load binary file over serial line (ymodem mode)

  • loop - infinite loop on address range

  • md - memory display

  • mm - memory modify (auto-incrementing)

  • mtest - simple RAM test

  • mw - memory write (fill)

  • nfs - boot image via network using NFS protocol

  • nm - memory modify (constant address)

  • printenv- print environment variables

  • protect - enable or disable FLASH write protection

  • rarpboot- boot image via network using RARP/TFTP protocol

  • reset - Perform RESET of the CPU

  • run - run commands in an environment variable

  • saveenv - save environment variables to persistent storage

  • setenv - set environment variables

  • sleep - delay execution for some time

  • tftpboot- boot image via network using TFTP protocol

  • usb - USB sub-system

  • usbboot - boot from USB device

  • version - print monitor version

  • NDS32>



Lab : EBIOS <-> U-boot

  • Compiler/build u-boot source code

  • Download u-boot image and replace EBIOS

  • Bootup EVB and verify the result



Standalone Program on Loader

  • Demo Program:

    • Demo shrinking function : printf -> sio_printf
    • Standalone program on u-boot/EBIOS…
    • Once execute this program, loader will jump to this program.
    • Create own stack
    • Explain interrupt mechanism and timer interrupt demo


Standalone Program Procedure Analysis



shrinking Printf (sio-printf) and calculate Code Size

  • Add Compiler parameter –Os : 0x9928 B->0x7452 B

  • Edit demo.text

  • sio_printf (0x48 B)

    • sio_vprintf (0x1D8 B)
      • ltoa (0x134 B)
    • sio_puts (0x34 B)
      • sio_putc (0x3C B)


Standalone Program Explanation

  • Interrupt:

    • Internal VIC mode
    • HW1(LCvector)-> HW1_dispatch_ISR(HandleUndef)-> Timer_Initialize-> IRQInstall(19, timer_ISR); // bit 19 for timer 1
  • Output:

    • demo: ELF file format executable file.
    • demo.bin: Binary format executable file.
    • demo.map: symbols and address.
    • demo.text: executable header information and dis-assambly codes.
  • exampleC.ld: complete example of linker script.



U-boot network display

  • DS32>

  • NDS32>

  • NDS32>

  • NDS32>printenv

  • bootdelay=3

  • baudrate=38400

  • netmask=255.255.255.0

  • ethaddr=00:41:71:99:00:1F

  • serverip=10.0.2.156

  • gatewayip=192.168.0.1

  • ipaddr=10.0.2.88

  • Environment size: 134/262140 bytes



U-boot network update and save

  • Environment size: 134/262140 bytes

  • NDS32>

  • bootdelay=3

  • baudrate=38400

  • netmask=255.255.255.0

  • ethaddr=00:41:71:99:00:1F

  • serverip=10.0.2.156

  • gatewayip=192.168.0.1

  • ipaddr=10.0.2.88

  • Environment size: 134/262140 bytes

  • NDS32>setenv gatewayip 10.0.2.154

  • NDS32>setenv serverip 10.0.2.60

  • NDS32>saveenv

  • Saving Environment to Flash...

  • env_flash.c[317]: adr: 805C0000h len 00040000h

  • Un-Protected 1 sectors

  • Erasing Flash...Erasing sector 7 ... ok.

  • Erased 1 sectors

  • Writing to Flash... ............................................................

  • ....

  • done

  • Protected 1 sectors

  • NDS32>



Check parameters and program Download via TFTP

  • Bank #0: 00000000 0 KB

  • ID1:890089, ID2:180018

  • Find Intel flash

  • Flash: 32 MB

  • NDS32>printenv

  • bootdelay=3

  • baudrate=38400

  • netmask=255.255.255.0

  • ethaddr=00:41:71:99:00:1F

  • ipaddr=10.0.2.88

  • serverip=10.0.2.60

  • gatewayip=10.0.2.254

  • Environment size: 132/262140 bytes

  • NDS32>tftpboot 0x00500000 demo.bin

  • ADDR: 00:41:71:99:00:1f

  • TFTP from server 10.0.2.60; our IP address is 10.0.2.88

  • Filename 'demo.bin'.

  • Load address: 0x500000

  • Loading: ##

  • done

  • Bytes transferred = 7452 (1d1c hex)

  • no auto boot ...



Execute Program

  • NDS32>go 0x00500000

  • ## Starting application at 0x00500000 ...

  • This is standalone program sample for Andes' EVB

  • Setup System Timer

  • Start while loop to print the System Timer:

  • 1 Seconds Passed

  • 1 Seconds Passed

  • 2 Seconds Passed

  • 3 Seconds Passed

  • 4 Seconds Passed

  • 4 Seconds Passed

  • 5 Seconds Passed

  • 5 Seconds Passed

  • 6 Seconds Passed

  • 7 Seconds Passed

  • 8 Seconds Passed

  • 8 Seconds Passed

  • 9 Seconds Passed

  • 9 Seconds Passed

  • 10 Seconds Passed

  • 11 Seconds Passed

  • 12 Seconds Passed

  • 12 Seconds Passed

  • 13 Seconds Passed

  • 13 Seconds Passed

  • 14 Seconds Passed

  • 14 Seconds Passed

  • 15 Seconds Passed

  • 15 Seconds Passed

  • 16 Seconds Passed

  • 16 Seconds Passed

  • 17 Seconds Passed

  • 18 Seconds Passed



Lab : standalone program

  • Compiler/build standalone program

  • Download standalone program via tftp

  • Execute standalone program on EVB board

  • Show time program but without accuracy

    • Update to accuracy


End of The File




Do'stlaringiz bilan baham:


Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2017
ma'muriyatiga murojaat qiling