Kicad PCB footprint

I have started using Kicad (again) on Mac OS X and it sort of works. There are some quirks, but nothing major so it looks quite usable.

After drawing the scheme I wanted to place the footprints of elements to PCB and bumped into a problem.

Where are the footprints?

After some googling I found that there should be a list of files in fp-lib-table, but how?

Finally I found the location of the file it’s in home directory under the Library/Preferences/kicad and since you need to add all the footprints by hand – obvious pain I found the script made in shell to create a file automatically.

Since I needed to hack the file and had some troubles with the idea I have decided to create similar thing in Python and here it is.

I hope the code is obvious (added some comments).

Thinking of GUI version, but not sure if there is interest 🙂

Showing variables with stm32f429 Discovery board

After a lot of playing with the above mentioned board I decided to play with accelerometers on the board. Might write about that in one of the next posts, if there will be interest 🙂

Anyway it appeared that variables (even simple integer) are not shown on the LCD. So it took me quite some time, to find where the error lies.

The culprit was missing linker options and I had to add –specs=nano.specs to the line:

$(CC) $(CFLAGS) $^ -o $@ -L../libs -lc -lstm32f4 -lnosys --specs=nano.specs

And the simple “let’s show a variable” program works:

#include "tm_stm32f4_ili9341.h"
#include <stdio.h>


int main(void) {
  char buffer[50];
  int value = 10;

  SystemInit();
   
  TM_ILI9341_Init();  
  TM_ILI9341_Fill(ILI9341_COLOR_RED);
  sprintf(buffer, "Value is: %d", value);
  TM_ILI9341_Puts(10, 70, buffer, &TM_Font_11x18, ILI9341_COLOR_BLACK, ILI9341_COLOR_RED);     
  return 0;
}

Gerber isolation milling

I am trying to create PCBs using Kicad and since I work more or less just on Mac OS X and try to avoid virtual environment with other OSes.

Anyway I managed to find properly compiled Kicad to work with Yosemite (can’t remember where I found it, but if there is an interest I will be searching for it 🙂 ).

The Kicad produces gerber used in the PCB industries which is all nice and dandy, but I would like to create a PCB by using CNC and for that you need something called isolation milling.

One of the possible solutions (so I have read, since I have to prepare some things to try isolation milling in vivo) is to use pcb2gcode.

I tried to compile it, but no go. Even did all the possible installation things with Homebrew. After a lot of kicking my ass and bending the brain I found the very, very simple solution. You just have to do:

export PKG_CONFIG_PATH=/opt/X11/lib/pkgconfig

and  off you go. Mind you, you need X11 to be installed.

LCD in open source way for stm32f4-discovery

So I was playing with LCD access with using the VX-toolset by Tasking and I have to admit I had a lot of troubles with creating some form of library or something to access LCD in different apps.

So I asked myself: is there an open source way to access the LCD?

And here is the answer:

1. Git clone https://github.com/MaJerle/stm32f429.git in a directory (e.g. /Users/bostjan/peskovnik/arm/stm32f4)

2. Use following makefile:

# put your *.o targets here, make should handle the rest!

SRCS = main.c

# all the files will be generated with this name (main.elf, main.bin, main.hex, etc)

PROJ_NAME=main

# that's it, no need to change anything below this line!

###################################################

CC=arm-none-eabi-gcc
OBJCOPY=arm-none-eabi-objcopy

CFLAGS  = -g -O2 -Wall -T../libs/stm32_flash.ld 
CFLAGS += -mlittle-endian -mthumb -mcpu=cortex-m4 -mthumb-interwork
CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16 -DUSE_STDPERIPH_DRIVER

###################################################

vpath %.c src

ROOT=$(shell pwd)

CFLAGS += -Iinc -I../libs
# ///
CFLAGS += -I../stm32f429/05-STM32F429_SPI/User/
CFLAGS += -I../stm32f429/00-STM32F4xx_STANDARD_PERIPHERAL_DRIVERS/CMSIS/Include/
CFLAGS += -I../stm32f429//00-STM32F4xx_STANDARD_PERIPHERAL_DRIVERS/CMSIS/Device/ST/STM32F4xx/Include/
CFLAGS += -I../stm32f429//00-STM32F4xx_STANDARD_PERIPHERAL_DRIVERS/STM32F4xx_StdPeriph_Driver/inc/
CFLAGS += -I../stm32f429/00-STM32F429_LIBRARIES/

SRCS += ../libs/startup_stm32f4xx.s  # add startup file to build
SRCS += ../libs/system_stm32f4xx.c
# ///
SRCS += ../stm32f429/00-STM32F429_LIBRARIES/tm_stm32f4_fonts.c
SRCS += ../stm32f429/00-STM32F429_LIBRARIES/tm_stm32f4_spi.c
SRCS += ../stm32f429/00-STM32F4xx_STANDARD_PERIPHERAL_DRIVERS/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_ltdc.c
SRCS += ../stm32f429/00-STM32F429_LIBRARIES/tm_stm32f4_ili9341_ltdc.c
SRCS += ../stm32f429/00-STM32F429_LIBRARIES/tm_stm32f4_sdram.c
SRCS += ../stm32f429/00-STM32F4xx_STANDARD_PERIPHERAL_DRIVERS/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_fmc.c
SRCS += ../stm32f429/00-STM32F4xx_STANDARD_PERIPHERAL_DRIVERS/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c

OBJS = $(SRCS:.c=.o)

###################################################

.PHONY: proj

all: proj

proj:     $(PROJ_NAME).elf

$(PROJ_NAME).elf: $(SRCS)
	$(CC) $(CFLAGS) $^ -o $@ -L../libs -lstm32f4
	$(OBJCOPY) -O ihex $(PROJ_NAME).elf $(PROJ_NAME).hex
	$(OBJCOPY) -O binary $(PROJ_NAME).elf $(PROJ_NAME).bin

clean:
	rm -f $(PROJ_NAME).elf
	rm -f $(PROJ_NAME).hex
	rm -f $(PROJ_NAME).bin

upload:
	st-flash write main.bin 0x8000000

3. The example of usage is rather simple:

#include "tm_stm32f4_ili9341.h"
#include <stdio.h>


int main(void) {
  SystemInit();
  TM_ILI9341_Init();
  TM_ILI9341_Fill(ILI9341_COLOR_RED);
  return 0;
}

So, just a background change.

 

That’s it.

And if it doesn’t work (the background doesn’t change) try pressing RESET button – on the board, of course.