ChibiOS icon indicating copy to clipboard operation
ChibiOS copied to clipboard

Support for the Olimex Olimexino STM32 board

Open mgsdk opened this issue 13 years ago • 17 comments

Added a definition for the Olimex Olimexino STM32 board and a simple blinker demo, taking into account the Maple USB bootloader already on the device.

mgsdk avatar Oct 21 '12 15:10 mgsdk

Is this going to be merged? I'm using an Olimexino-STM32 too and although I havn't tested all features this patch has been working flawlessly so far.

speakman avatar Aug 28 '13 07:08 speakman

it wont be merged via here as this is just a mirror of the chibios svn repo

trsaunders avatar Aug 28 '13 09:08 trsaunders

Just as a small note, I never got the ADC working on the board, which was the primary reason for the purchase. So there is still some work which needs to be done to this before it is ready for a merge with the codebase I guess.

mgsdk avatar Aug 28 '13 09:08 mgsdk

Tested with simplified version of ChibiOS\testhal\STM32F1xx\ADC (added serial usb logging). ADC working fine with and without maple bootloader

Furcube avatar Aug 28 '13 18:08 Furcube

Just had trouble getting serial port working. Manually setting the TX and RX pin to output respectively input finally solved it. Should that be handled by sdStart? I didn't see any other serial examples setting pin directions.

speakman avatar Sep 03 '13 22:09 speakman

If someone still interested, I've tested this code (ADC and LEDs) with maple bootloader and it works like a charm!

gordon-quad avatar Sep 30 '13 19:09 gordon-quad

I would indeed like this to be merged. Maybe the serial pin setting should be fixed, but I'm not sure it's the serial HAL responsible for setting up pin direction? If it is, I can send a patch.

speakman avatar Oct 02 '13 07:10 speakman

Good day to every one, Is Giovanni from Brisbane Australia. In this days I was trying to use the Olimex Olimexino STM32 (Rev E) board with Chibios 2.6.3

I am using the IDE Chibi Studio : (http://sourceforge.net/projects/chibios/files/ChibiStudio/) a tool based on Eclipse.

I have create a new C project and added the files into the folders :

  • demo (OLIMEX-Olimexino-STM32) And linked the folder to :
  • board (OLIMEX_OLIMEXINO_STM32)
  • os (chibios/os)

Once compiled seems all working without errors.

I am using the Olimex ARM-USB-TINY-H as flash programmer , under win7 i have installed it using the ftd-drivers provided on the Olimex website (https://www.olimex.com/Products/ARM/JTAG/ARM-USB-TINY-H/).

To write the chip I am using the CooCox CoFlash software, seems working well with the ftd drivers (http://www.coocox.org/CoFlash_Programmer.htm).

Now I have this problems:

  • once the chip is written nothing happens , no blinking leds
  • tried also to modify the pin and port of the leds, in the board.h nothing happens.

Do you have any suggestions ? Can someone pass me the binary of a blinking test? Which tools do you use to write the chip STM32F103RBT6 of the Olimex Olimexino STM32 (Rev E) board ?

IlGioMagnifico avatar Mar 28 '14 02:03 IlGioMagnifico

Actually, I remember having similar problems. Then I re-installed the bootloader and modified the ld-script accordingly, and then it all worked. With the exact same code. Are there any initialization not being done correctly? Can you give it a go with the Maple bootloader installed?

speakman avatar Mar 31 '14 06:03 speakman

Thanks Speakman for Your quick reply, I have solved the issue in this way:

  1. Using the IDE Chibi Studio (http://sourceforge.net/projects/chibios/files/ChibiStudio/) I have open the c/c++ Project (the sample one that comes with Chibi Studio) called ARMCM3-STMF32F103

  2. In the project, using the linked folder "board" I have replaced the board.h with the one that is in this repository

  3. Change also the file main.c with the one in this repository.

Once compiled , I have used my Olimex ARM-USB-TINY-H + 24 to 10 pin module + FTDI drivers (https://www.olimex.com/Products/ARM/JTAG/ARM-USB-TINY-H/) to transfer the .elf to the STM32F103RBT6 of the Olimex Olimexino STM32 (Rev E) board .

To do this I have used the tool CooCox CoFlash software (http://www.coocox.org/CoFlash_Programmer.htm) , set up with the cofiguration in this guide (https://www.olimex.com/Products/ARM/JTAG/_resources/How_to_run_CooCox_with_Olimex_JTAGs_v2.pdf) :

  • device st -> stm32f103rb
  • adapter -> olimex - OpenOCD
  • maxclock -> 500 Khz
  • port -> Jtag

Remember to select the .elf file ( under command -> program -> datafile ) that usually is in : C:\ChibiStudio\chibios\demos\ARMCM3-STM32F103\build

I did not have time to find out why was not working previously , but I hope that can be useful what I wrote to someone beginner like me!

Did anyone used the Olimex Olimexino STM32 with Chibios OS and CanBus ? Can anyone help me with the initialization of the can bus in normal mode with chibios ?

IlGioMagnifico avatar Apr 03 '14 01:04 IlGioMagnifico

This should still have to be sorted out somehow.

Regarding CAN, I'm just about to get it going. Tomorrow we will start our first test with CAN communication with a Beagle Bone Black as a central node. I think I did got CAN working while evaluating Chibios, but it's been a while and I can't really remember. Tomorrow, I will find out for sure. :)

speakman avatar Apr 07 '14 08:04 speakman

Good day Speakman,

I am still working with the Olimex Olimexino STM32 , I have the code for :

  • blinking led and CanBus working and tested on Maple Ide (https://leaflabs.com/)
  • blinking led and CanBus working and tested on CooCox Coide (www.coocox.org)

The next step will be get the CanBus working with Chibios under ChibiStudio (http://sourceforge.net/projects/chibios/files/ChibiStudio/)

If any one needs code for the Olimex Olimexino STM32 just ask me!

IlGioMagnifico avatar Apr 08 '14 03:04 IlGioMagnifico

Did you ever get CAN working? How much does it differ from this: https://github.com/mabl/ChibiOS/blob/master/testhal/STM32F1xx/CAN/main.c

I've been working with the CAN for a few hours finally, and used the above test to get it going. As long as I use "loopback" flag it works as it should, but when I remove the loopback (to hopefully find something on the CAN D+ or D-) nothing happens on those pins.

speakman avatar Apr 15 '14 22:04 speakman

Good day to every one, good day Speakman, Just a quick reply,i will provide more details later.

First at all I will suggest to every one to follow this guide to Stm32 programming: http://www.diller-technologies.de/stm32.html You can easly translate in English using Google Chrome or Google Translator (I really suggest You to read it).

When You remove the loopback,I have seen that the writing on the can in working but not the Read,an this because you have to setup an software interrupt to manage the read from the canbus.

To do this You have to setup in this way:

.....

NVIC_InitTypeDef NVIC_InitStructure; NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure);

CAN_ITConfig(CAN1, CAN_IT_FMP0, ENABLE);

CAN_FilterInitTypeDef CAN_FilterInitStructure; CAN_FilterInitStructure.CAN_FilterNumber = 0; CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask; CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit; CAN_FilterInitStructure.CAN_FilterIdHigh = 0x0123 << 5; CAN_FilterInitStructure.CAN_FilterIdLow = 0x0000; CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0xFFFF; CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0xFFFF; CAN_FilterInitStructure.CAN_FilterFIFOAssignment = 0; CAN_FilterInitStructure.CAN_FilterActivation = ENABLE; CAN_FilterInit(&CAN_FilterInitStructure);

while (1) {} }

void USB_LP_CAN1_RX0_IRQHandler(void) { CanRxMsg RxMessage; CAN_Receive(CAN1, CAN_FIFO0, &RxMessage); if (RxMessage.Data[0] == 1) { GPIO_WriteBit(GPIOA, GPIO_Pin_5, Bit_SET); } else { GPIO_WriteBit(GPIOA, GPIO_Pin_5, Bit_RESET); } }

IlGioMagnifico avatar Apr 16 '14 23:04 IlGioMagnifico

Good day to every one, using this guide : (http://www.diller-technologies.de/stm32.html )

/*******************************************************************************

  • File Name : can_cnfg.h
  • Author :
  • Version :
  • Date :
  • Description : Header for CanBus ------------------------------------------------------------------------------*/

/* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __CAN_CNFG_H #define __CAN_CNFG_H

/* Includes ------------------------------------------------------------------*/ // Includes for STM32F103RBT6 #include "stm32f10x_conf.h" // make shore that you have the CanBus and Gpio library without comments #include "stm32f10x.h"

/* Exported types ------------------------------------------------------------/ / Exported constants --------------------------------------------------------/ / Uncomment the line corresponding to the STMicroelectronics evaluation board used to run the example */ #if !defined(USE_OLIMEXINO_STM32) #define USE_OLIMEXINO_STM32 #endif

/* Define the STM32F10x hardware depending on the used board */ #ifdef USE_OLIMEXINO_STM32 #define RCC_APB2Periph_GPIO_CAN1 RCC_APB2Periph_GPIOB #define GPIO_Remapping_CAN1 GPIO_Remap1_CAN1 #define GPIO_CAN1 GPIOB
#define GPIO_Pin_CAN1_RX GPIO_Pin_8 #define GPIO_Pin_CAN1_TX GPIO_Pin_9 #endif

CanTxMsg TXMessage; CanRxMsg RXMessage;

short receive_message;

/* Exported macro ------------------------------------------------------------/ / Exported functions ------------------------------------------------------- */ void can_cnfg_Initialize(void); void CAN_Configuration(void); void NVIC_Configuration(void); void USB_LP_CAN1_RX0_IRQHandler(void); void Filter_Configuration(void); void CAN_SendMessage(void);

#endif

/*******************************************************************************

  • File Name : can_cnfg.c
  • Author :
  • Version :
  • Date :
  • Description : CanBus library ------------------------------------------------------------------------------*/

/* Includes ------------------------------------------------------------------*/ #include "can_cnfg.h"

void can_cnfg_Initialize(void) { CAN_Configuration(); NVIC_Configuration(); Filter_Configuration();

TXMessage. StdId  =  Broadcast_Node_Address ;
TXMessage. ExtId  =  0 ;
TXMessage. RTR  = CAN_RTR_DATA ;
TXMessage. IDE  = CAN_ID_STD ;
TXMessage. DLC  =  8 ;

TXMessage. Data [ 0 ]  =  0 ;
TXMessage. Data [ 1 ]  =  0 ;
TXMessage. Data [ 2 ]  =  0 ;
TXMessage. Data [ 3 ]  =  0 ;
TXMessage. Data [ 4 ]  =  0 ;
TXMessage. Data [ 5 ]  =  0 ;
TXMessage. Data [ 6 ]  =  0 ;
TXMessage. Data [ 7 ]  =  0 ;

receive_message=0;

}

void CAN_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure; CAN_InitTypeDef CAN_InitStructure;

RCC_APB1PeriphClockCmd(RCC_APB1Periph_CAN1, ENABLE);
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO, ENABLE);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_CAN1_RX;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIO_CAN1, &GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_CAN1_TX;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIO_CAN1, &GPIO_InitStructure);

GPIO_PinRemapConfig(GPIO_Remap1_CAN1 , ENABLE);

// CAN-Bitrate 32 MHz / 2 / (1 + 11 + 4) = 1 MBit/s
CAN_InitStructure.CAN_Prescaler = 2;
CAN_InitStructure.CAN_SJW = CAN_SJW_2tq;
CAN_InitStructure.CAN_BS1 = CAN_BS1_11tq;
CAN_InitStructure.CAN_BS2 = CAN_BS2_4tq;
CAN_InitStructure.CAN_Mode = CAN_Mode_Normal;
CAN_InitStructure.CAN_TTCM = DISABLE;
CAN_InitStructure.CAN_ABOM = DISABLE;
CAN_InitStructure.CAN_AWUM = DISABLE;
CAN_InitStructure.CAN_NART = ENABLE;
CAN_InitStructure.CAN_RFLM = DISABLE;
CAN_InitStructure.CAN_TXFP = DISABLE;
CAN_Init(CAN1, &CAN_InitStructure);

}

void NVIC_Configuration(void) { NVIC_InitTypeDef NVIC_InitStructure; NVIC_InitStructure.NVIC_IRQChannel = USB_LP_CAN1_RX0_IRQn; NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0; NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0; NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&NVIC_InitStructure);

  CAN_ITConfig(CAN1, CAN_IT_FMP0, ENABLE);

}

void Filter_Configuration(void) { // All IDs CAN_FilterInitTypeDef CAN_FilterInitStructure; CAN_FilterInitStructure.CAN_FilterNumber = 0; CAN_FilterInitStructure.CAN_FilterMode = CAN_FilterMode_IdMask; CAN_FilterInitStructure.CAN_FilterScale = CAN_FilterScale_32bit; CAN_FilterInitStructure.CAN_FilterIdHigh = 0x0000; CAN_FilterInitStructure.CAN_FilterIdLow = 0x0000; CAN_FilterInitStructure.CAN_FilterMaskIdHigh = 0x0000; CAN_FilterInitStructure.CAN_FilterMaskIdLow = 0x0000; CAN_FilterInitStructure.CAN_FilterFIFOAssignment = 0; CAN_FilterInitStructure.CAN_FilterActivation = ENABLE; CAN_FilterInit(&CAN_FilterInitStructure); }

void USB_LP_CAN1_RX0_IRQHandler(void) { CAN_Receive(CAN1, CAN_FIFO0, &RXMessage); receive_message=1; // I am using this variable as a flag once a message is received LED_Toggle(LED1); // toggle a led on the board once the message is received }

void CAN_SendMessage(void) { uint8_t transmit_mailbox = 0;

/*
TXMessage. StdId  =  Broadcast_Node_Address ;
TXMessage. ExtId  =  0 ;
TXMessage. RTR  = CAN_RTR_DATA ;
TXMessage. IDE  = CAN_ID_STD ;
TXMessage. DLC  =  8 ;
*/

transmit_mailbox = CAN_Transmit(CAN1, &TXMessage);
if(transmit_mailbox!=CAN_TxStatus_NoMailBox)
{
 LED_Toggle(LED2);   // toggle a led on the board once the message is sent
}

}

/* I am using the amazing CooCox Ide , and I will use till I will get all the functions that I need working on the Olimexino STM32, then I will start the porting using Chibios and ChibiStudio Ide.

If anyone is interested I can send my project files, just to have something working if You are a beginner like me. */

IlGioMagnifico avatar Apr 21 '14 06:04 IlGioMagnifico

I've got it all up'n'running using pure Chibios, but I did have to make some minor adjustifications in Chibios. I will try to put up with a Pull Request, but my time is pretty limited. Eventually it will be here. :)

speakman avatar Apr 23 '14 07:04 speakman

Hi i would appreciate a copy of your full can project files , i am running around in circles ! haha ,please send to davey21 at outlook dot com

thanks

CNCBASHER avatar Jun 14 '14 10:06 CNCBASHER