Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for the Olimex Olimexino STM32 board #3

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mgsdk
Copy link

@mgsdk mgsdk commented Oct 21, 2012

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.

@speakman
Copy link

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.

@trsaunders
Copy link

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

@mgsdk
Copy link
Author

mgsdk commented Aug 28, 2013

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.

@Furcube
Copy link

Furcube commented Aug 28, 2013

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

@speakman
Copy link

speakman commented Sep 3, 2013

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.

@gordon-quad
Copy link

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

@speakman
Copy link

speakman commented Oct 2, 2013

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.

@IlGioMagnifico
Copy link

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 ?

@speakman
Copy link

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?

@IlGioMagnifico
Copy link

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 ?

@speakman
Copy link

speakman commented Apr 7, 2014

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. :)

@IlGioMagnifico
Copy link

Good day Speakman,

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

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!

@speakman
Copy link

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.

@IlGioMagnifico
Copy link

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
Copy link

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.
*/

@speakman
Copy link

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. :)

@CNCBASHER
Copy link

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

tzarc referenced this pull request in tzarc/ChibiOS May 11, 2021
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@13780 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
tzarc referenced this pull request in tzarc/ChibiOS Jun 16, 2021
git-svn-id: http://svn.osdn.net/svnroot/chibios/trunk@13780 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants