How to run DS-5 program at Phytec Cosmic+ board from FLASH ?

cancel
Showing results for 
Search instead for 
Did you mean: 

How to run DS-5 program at Phytec Cosmic+ board from FLASH ?

Jump to solution
1,424 Views
dragan
Contributor III

Respected Colleagues,

I am new in ARM DS-5 and Freescale Vybrid processors, so please be easy on me.

I have successfully implemented DS-5 sample projects (Freescale-Vybrid-VF6xx-A5_RAM and Freescale-Vybrid-VF6xx-M4_RAM) under DS-5 for Phytec Cosmic+ Board and debug works fine. Hello World programs execution are OK on both Vybrid cores (A5 and M4). But those examples are executed in RAM.

My question is how to make firmware which can be downloaded to Cosmic+ Board FLASH, and executed from FLASH ? How to write scatter file, or make memory Configuration? Is it possible to download firmware to FLASH trough USB Cable, like in debug case, or I must have some programmer? Where can I find some firmware examples which are executed from FLASH ? Is it possible that examples for Vybrid are so rare or not exist at all?

Also, is it possible to make a Keil project for Vybrid M4 core with MQX RTOS ? I know how to make project, because I work in Keil for 5 years, but I do not see VF61 processor in the list of processors. Can it be some other M4 processor, and if it can, which one?

Thanks in advance.

Regards,

Dragan

Labels (3)
1 Solution
425 Views
rendy
NXP Employee
NXP Employee

Hi Dragan,

I've tried your example. You are experiencing Segmentation Faults and it is absolutely OK and expected.

In an application running atop of an operating system, you cannot access hardware directly as you do it in your example. This is called Memory protection - segmentation fault is a result of accessing memory which doesn't belong to your program. I would just remind - in OS, the only memory parts which you can use are those which you get from OS - you allocate them (malloc). For accessing peripherals you have to use drivers. Imagine you would run your program twice - the operating system then has to decide which instance of your program will controll the LED/pins - this is called Resource management. Another reason why you can't access memory directly is because of Memory management technique called Virtual memory. This means that when your program sees something stored at the address 0x4000, it doesn't mean it is really stored at that address in the physical memory.

But end of mentoring Smiley Happy Below there is a code snippet which demonstrates how work with GPIO pins through GPIO driver in Timesys Linux:

First you enable GPIO pins in shell to be used by the driver, this creates a gpioXX directory for each pin in '/sys/class/gpio/':

# echo 22 > /sys/class/gpio/export

# echo 23 > /sys/class/gpio/export

# echo 24 > /sys/class/gpio/export

# echo 25 > /sys/class/gpio/export

Then you set them to output:

# echo out > /sys/class/gpio/gpio22/direction

# echo out > /sys/class/gpio/gpio23/direction

# echo out > /sys/class/gpio/gpio24/direction

# echo out > /sys/class/gpio/gpio25/direction

Both of the previous actions can also be done in code through standard 'open', 'write', 'close' calls - like below.

Then you can turn the leds on/off like this:

int led;

if ((led = open("/sys/class/gpio/gpio22/value", O_WRONLY)) < 0 ) {

    printf("Failed\n");

} else {

    write(led, "0", 1);

    getchar();

    write(led, "1", 1);

    getchar();

    write(led, "0", 1);

    getchar();

    write(led, "1", 1);

}

Or again in shell:

# echo 1 > /sys/class/gpio/gpio22/value

# echo 0 > /sys/class/gpio/gpio22/value

This is a standard way how to interact with drivers in unix-like systems.

The numbers 22 - 25 are LED GPIO pins, but you can use other numbers for other pins.

Hope this helps

Rene

View solution in original post

25 Replies
423 Views
dragan
Contributor III

Respected colleagues,

thanks to rendy who gave mi a simple and easy to understand answer, I have made in no time an Timesys Linux example project for Phytec Vybrid Cosmic+ Board.

To allow project to access I/O ports, that I/O port access must be disabled in the Kernel file board-pcl052 and rebuild the Kernel.

Project File and modified board-pcl052 are in attachment.

Again thanks to rendy.

With best regards,

Dragan Kujovic

0 Kudos
426 Views
rendy
NXP Employee
NXP Employee

Hi Dragan,

I've tried your example. You are experiencing Segmentation Faults and it is absolutely OK and expected.

In an application running atop of an operating system, you cannot access hardware directly as you do it in your example. This is called Memory protection - segmentation fault is a result of accessing memory which doesn't belong to your program. I would just remind - in OS, the only memory parts which you can use are those which you get from OS - you allocate them (malloc). For accessing peripherals you have to use drivers. Imagine you would run your program twice - the operating system then has to decide which instance of your program will controll the LED/pins - this is called Resource management. Another reason why you can't access memory directly is because of Memory management technique called Virtual memory. This means that when your program sees something stored at the address 0x4000, it doesn't mean it is really stored at that address in the physical memory.

But end of mentoring Smiley Happy Below there is a code snippet which demonstrates how work with GPIO pins through GPIO driver in Timesys Linux:

First you enable GPIO pins in shell to be used by the driver, this creates a gpioXX directory for each pin in '/sys/class/gpio/':

# echo 22 > /sys/class/gpio/export

# echo 23 > /sys/class/gpio/export

# echo 24 > /sys/class/gpio/export

# echo 25 > /sys/class/gpio/export

Then you set them to output:

# echo out > /sys/class/gpio/gpio22/direction

# echo out > /sys/class/gpio/gpio23/direction

# echo out > /sys/class/gpio/gpio24/direction

# echo out > /sys/class/gpio/gpio25/direction

Both of the previous actions can also be done in code through standard 'open', 'write', 'close' calls - like below.

Then you can turn the leds on/off like this:

int led;

if ((led = open("/sys/class/gpio/gpio22/value", O_WRONLY)) < 0 ) {

    printf("Failed\n");

} else {

    write(led, "0", 1);

    getchar();

    write(led, "1", 1);

    getchar();

    write(led, "0", 1);

    getchar();

    write(led, "1", 1);

}

Or again in shell:

# echo 1 > /sys/class/gpio/gpio22/value

# echo 0 > /sys/class/gpio/gpio22/value

This is a standard way how to interact with drivers in unix-like systems.

The numbers 22 - 25 are LED GPIO pins, but you can use other numbers for other pins.

Hope this helps

Rene

View solution in original post

423 Views
dragan
Contributor III

Thank you Rene,

at last correct direction !

It works, but it is much, much slower than direct access to CPU's registers without Linux.

Is it possible to make application under Linux which can allow direct access to CPU registers, like in my example project?

With best regard,

Dragan Kujovic

0 Kudos
423 Views
rendy
NXP Employee
NXP Employee

Yes, this driver is definitely slower and usable only in very general cases. In case you have some specific needs, you can write your own driver which will perform better. Of course you will never get the predictability and determinism of bare metal solution as operating system always brings some overhead. But this is the exact use case for Vybrid's heterogeneous multiprocessing model. Write your general application logic in Linux and run it on A5 core and use bare metal code on M4 core for the time-critical part of your solution.

0 Kudos
423 Views
dragan
Contributor III

Dear Naoum and Karina,


thanks for helping me.

I made some progress.

Now I can make GCC project under ARM DS-5, compile it, make Linux executable, debug code on the target board, and transfer executable file on the SD card with Timesys Linux distribution.

So, I managed to transfer executable file to Phytec Cosmic+ board SD card with ARM DS-5 Remote Systems connection trough USB OTG/POWER Connector (RNDIS Gadget), or to debug code on the target board trough USB OpenSDA Connector (Keil Software OpenSDA CMSIS-DAP).

Now, that executable file which is saved on the SD card after power cycle can run again.

I have now problem with Timesys Linux distribution for Phytec Cosmic+ board, because after boot, some Timesys application is running (pressing switches turn LED's on and off). Because of that, part of my application which try to access those switches and LED's crash.

My question for Timesys is how to disable mentioned application in original Timesys Linux distribution without making new Linux distribution ?

Also, does Timesys have some tutorial how to change boot (and Linux distribution host) from SD card to NAND FLASH on Phytec Cosmic+ board, because this board have boot choice jumpers (SD card / NAND)?

Another problem is that I can not make Ethernet link with Phytec Cosmic+ board, although I have two LAN connectors on my PC, and tried what I have found on the Timesys web site. Does Timesys have some tutorial about this, because it is tricky? Why it doesn't work without any problems from the box like at Raspberry Pi board with Raspbian Linux distribution?

Any help will be greatly appriciated. Thanks in advance.

With best regards,

Dragan Kujovic

0 Kudos
423 Views
timesyssupport
Senior Contributor II

Hello Dragan,

My question for Timesys is how to disable mentioned application in original Timesys Linux distribution without making new Linux distribution ?

As Edward mentioned, you can run 'chmod -x /path/to/initscript' to remove execution permissions from an initscript, disabling it from running at startup.

Also, does Timesys have some tutorial how to change boot (and Linux distribution host) from SD card to NAND FLASH on Phytec Cosmic+ board, because this board have boot choice jumpers (SD card / NAND)?

We do not have a document for the Cosmic+ for booting from NAND Flash. However, I would imagine this document would be quite similar if you wish to try it:

HOWTO Boot from NAND on Vybrid Tower using U-Boot 2011.12 | Timesys Embedded Linux

Another problem is that I can not make Ethernet link with Phytec Cosmic+ board, although I have two LAN connectors on my PC, and tried what I have found on the Timesys web site. Does Timesys have some tutorial about this, because it is tricky? Why it doesn't work without any problems from the box like at Raspberry Pi board with Raspbian Linux distribution?

Are you using the latest kernel sources? One of the recent kernel patches was to fix a bug with ethernet not working. Here is a link to a build that has this patch:

Embedded Linux software, platform, distributions, packages, libraries, development and debugging too...

You should be able to follow the instructions for the pcm052 in order to properly network your host and target:

Timesys Getting Started Guide for PHYTEC phyCORE Vybrid Development Kit | Timesys Embedded Linux

Thanks,

Timesys Support

0 Kudos
423 Views
dragan
Contributor III

Respected Serah Peterson, Naoum Gitnik, Karina Valencia Aguilar and Edward Karpicz

I have tried everything that community advised and your documents stated, but with no satisfactory results.

Why you don't make simple example projects for most popular Vybrid boards for every part of the hardware like Keil does for almost all CPU families ?

After almost two years Freescale Vybrid CPU can not be used as a product for market because of poor software support, and idea with two cores for OS and RTOS is really great.

I have posted today simple DS-5 GCC project which can be compiled in ARM DS-5 without warnings and errors. So, please, if you have somebody in your company who can try this and make alive under your Timesys Linux, it will be a good starting point for further programming.

If you can, please do it, not only because of me, but for sake of all quiet members of Freescale community.


Once again Freescale Vybrid is a great product, but I can not see a bright future for Vybrid CPU's without better software support.


With best regards,

Dragan Kujovic




423 Views
karina_valencia
NXP Apps Support
NXP Apps Support

rendy can you   add your comments about previous  update from Dragan?

0 Kudos
423 Views
kef2
Senior Contributor IV

Dragan,

  • I have now problem with Timesys Linux distribution for Phytec Cosmic+ board, because after boot, some Timesys application is running (pressing switches turn LED's on and off). Because of that, part of my application which try to access those switches and LED's crash.
  • My question for Timesys is how to disable mentioned application in original Timesys Linux distribution without making new Linux distribution ?

The place Linux programs are started at boot is /etc/init.d folder. There you should find executable like S80-timesys-xxxx, which launches specific demo application. You need to remove this executable or chmod -x it.

0 Kudos
423 Views
karina_valencia
NXP Apps Support
NXP Apps Support

timesyssupport can you  help with this case?

0 Kudos
423 Views
naoumgitnik
Senior Contributor V

Dear Dragan,

It is a real pity you did not mention in your initial request that you had the OpenSDA interface - I'd refer you to it from the very beginning. The point is that, although Phytec is our "board partner", we do not know their designs' specifics.

Now, while asking about the Ethernet connection, you are not providing any information about how the Ethernet PHY is connected to Vybrid, e.g., what the RMII Reference clock source is (usually on the PTA6 IO ball), and it influences the Vybrid settings impacting its operation. If the same way as on our Tower board, then you may copy the relevant settings from our design; if not, you will need additional instructions.

Sincerely, Naoum Gitnik.

[Dear timesyssupport, may you take a look at the customer's questions in his last message, please?]

423 Views
speterson
Contributor III

Hi Dragan,

The button to LED implementation is done in the Linux board file. The connection between the user buttons and LEDs can be seen here: arch/arm/mach-mvf/board-pcl052.c

static struct gpio_led pcl052_gpio_leds[] = {

{

                .name   = "LED1",

                .gpio   =  GPIO_LED_1,

                .default_trigger = "gpio",

                .trigger_gpio = GPIO_BTN_1,

        },

        {

                .name   = "LED2",

                .gpio   =  GPIO_LED_2,

                .default_trigger = "gpio",

                .trigger_gpio = GPIO_BTN_2,

        },

        {

                .name   = "LED3",

                .gpio   =  GPIO_LED_3,

                .default_trigger = "gpio",

                .trigger_gpio = GPIO_BTN_3,

        },

        {

                .name   = "LED4",

                .gpio   =  GPIO_LED_4,

                .default_trigger = "gpio",

                .trigger_gpio = GPIO_BTN_4,

        },

};

To remove this functionality you would need to rebuild the kernel without this support. You should be able to quickly remove this support from the kernel by taking out the pcl_init_gpio() call in the pcl052_board_init method.

To boot U-Boot from NAND you will need to modify the boot jumpers on the Cosmic board. For NAND boot this setting is as follows:

     JP2: 1+6; 3+4; 5+2

For booting Linux from NAND, the HOWTO Boot from NAND on Vybrid Tower Board document on LinuxLink is a great reference for implementation.

For the Ethernet issue, what software do you have running on the kit? Are you using the default images that were shipped with the board? Are the LEDs on the RJ45 connector blinking as expected when connecting a cable to the board? Is there an eth0 entry in ifconfig?

423 Views
dragan
Contributor III

Respected Serah, Naoum, Karina and Edward,

in the process of trying to update Kernel, I have noticed that Timesys has not made SPI driver for Phytec Cosmic+ Board. Is it possible that nobody needs SPI (for external LCD's, ADC's, DAC's. etc.)? Or Timesys think that there is no SPI on the Phytec Cosmic+ Board as stated in the file board-pcl052.c "no devices on PCL-052". As I understood, Cosmic+ Board is development board for testing and using everything on the external connectors. For me the SPI is the first on the list, because I need to connect a SPI ADC to Cosmic+ board. I don't know what is the problem to port that driver if the CPU is the same on the Freescale TOWER, Phytec SOM and Phytec Cosmic+ Board.

Picture with pins assignment for all of the mentioned boards is in attachment.

With best regards,

Dragan Kujovic

0 Kudos
423 Views
naoumgitnik
Senior Contributor V

Dear Timesys Support,

May you comment on availability of the SPI driver for our Vybrid-based boards, please, that Dragan can adapt for his Phytec board?

Thanks, Naoum Gitnik.


Dear dragan,

Have you contacted Phytec with the SPI driver availability question as well?

Regards, Naoum Gitnik.

0 Kudos
423 Views
timesyssupport
Senior Contributor II

Hello Dragan,

speterson can correct if I am wrong, but there is currently no DSPI driver for the pcl052 board.  If you are looking to create your own DSPI driver, a starting point could be the DSPI driver in the 3.0 or 3.13 kernel for the Vybrid Tower. Let me know if you have any questions.

Thanks,

Timesys Support

0 Kudos
423 Views
speterson
Contributor III

Yes, I can confirm that we do not have any DSPI support examples currently in the board file for our phyCORE-Vybrid SOM solutions.

This is because we do not have any devices on the SOM or baseboard that utilize the DSPI interface. Our on board SPI NOR flash is connected to the QSPI interface. As Timesys support mentioned the board file for the Freescale tower would be a good reference for implementation.

0 Kudos
423 Views
dragan
Contributor III

Respected speterson, naoumgitnik, karinavalencia and kef2

I made a new Kernel build for Phytec Cosmic+ board with changed board-pcl052 file (removed GPIO use in the file and added SPI0 support).

Also, I made a test project for ARM DS-5 which make executable file for Linux.

It is simple application which have access to a timer, serial port, LED and switches. Project compile without any warnings and errors and work OK in debug mode trough OpenSDA.

But, when I transfer executable file to the SD card and start it under Timesys Linux distribution, only printf works trough serial port. If I try to access Timer, I/O ports, Linux return error "Segmentation fault".

Can somebody please check attached test project and try to make it to work flawlessly ? For now I obviously do non know how to make correct DS-5 project for Vybrid CPU.

It will be very nice for all begginers in Vybrid code development to have some healthy starting point with project which can work at A5 and M4 core.

Thanks in advance.

With best regards,

Dragan Kujovic

0 Kudos
423 Views
dragan
Contributor III

Respected Serah,

> To remove this functionality you would need to rebuild the kernel without this support.

> You should be able to quickly remove this support from the kernel by taking out the pcl_init_gpio() call in the pcl052_board_init method.


Excuse me, I have tried, but I admit I don't know how to change something in the Kernel and to rebuild it after that (I am Hardware Design Engineer and a Windows,Visual Studio, Keil, MPLAB C / C++ / C# / Java programmer, so for now, I now very little about Linux).


Can you help me with this with some tutorial, or if it is not big trouble for you, can you make a changed image and put it somewhere on your site for download. I tried with your Factory - Automated Embedded Linux Build System but it is too much complicated for my current knowledge.


Our goal is to use Phytec SOM modules for our devices which must have Real Time measurements on M4 core (Power quality, current, voltage with FFT analysys) at exact timing i.e. 1 ms, and user interface (LAN, LCD, SD, USB etc.) on the A5 core. Now, for that purpose we have two separate CPU's with interconnection.


Thanks i advance.


With best regards,

Dragan Kujovic


0 Kudos
423 Views
speterson
Contributor III

Dragan,

Do you have a Linux Host PC that you can install the Timesys factory on? There are instructions for how to do so using the Quickstart Guide: Cosmic Board-Vybrid Quickstart-QS1.0 - PHYTEC Wiki

  • Section 4.2.2 for setup instructions
  • Section 5.2 for build instructions

The Timesys Desktop factory is required for making source code modifications and building a custom kernel. This will be beneficial to have setup for your development. The Web Factory is useful when you want to change the packages built into the root filesystem but not the source code.

0 Kudos
423 Views
dragan
Contributor III

Respected Serah,

> The Timesys Desktop factory is required for making source code modifications and building a custom kernel.

for Phytec Cosmic+ Board do I have to use:

pcl052-development-environment.sh

pcl052-factory-installer.sh

or

pcm052-development-environment.sh

pcm052-factory-installer.sh

Please advice.

With best regards,

Dragan Kujovic

0 Kudos