ulibSD a library for use SD cards in SPI mode with uControllers.

ulibSD

It’s a library for use SD cards in SPI mode with uControllers, entirely written
in C. This library can work with SD cards and also has the possibility to
emulate the behavior in a PC file (GNU/Linux) using the macro _M_IX86. It’s for
debugging purposes. The data transfer is oriented to 512 byte size,
remember this.

Public methods

ulibSD has four public methods:

  • SD_Init: Initialization the SD card.
  • SD_Read: Read a single block of data.
  • SD_Write: Write a single block of data.
  • SD_Status: Allows know status of SD card.

Those methods require a device descriptor.

How is possible port the code to my platform?

This library uses a spi_io.h header. Here are defined the low-level methods
associated with the hardware. Those methods are:

  • SPI_Init: Initialize SPI hardware.
  • SPI_RW: Read/Write a single byte. Returns the byte that arrived.
  • SPI_Release: Flush of SPI buffer.
  • SPI_CS_Low: Selecting function in SPI terms, associated with SPI module.
  • SPI_CS_High: Deselecting function in SPI terms, associated with SPI module.
  • SPI_Freq_High: Setting frequency of SPI’s clock to maximun possible.
  • SPI_Freq_Low: Setting frequency of SPI’s clock equal or lower than 400kHz.
  • SPI_Timer_On: Start a non-blocking timer in milliseconds.
  • SPI_Timer_Status: Check the status of non-blocking timer.
  • SPI_Timer_Off: Stop of non-blocking timer.

You need write the proper code for this methods. I leave a spi_io.c.example
file for use as guideline. I hope this helps to you understand how is the logic
of portability. This example is for KL25Z board using my OpenKL25Z framework.

Also you need verify and adapt the integer types in the integer.h file.

Example of use

SD_DEV dev[1];          // Create device descriptor
uint8_t buffer[512];    // Example of your buffer data
void main(void)
{
  SDRESULTS res;
  // Part of your initialization code here
  if(SD_Init(dev)==SD_OK)
  {
    // You can read the sd card. For example you can read from the second
    // sector the set of bytes between [04..20]:
    // - Second sector is 1
    // - Offset is 4
    // - Bytes to count is 16 (20 minus 4)
    res = SD_Read(dev, (void*)buffer, 1, 4, 16);
    if(res==SD_OK)
    {
      // Maybe you wish change the data on this sector:
      res = SD_Write(dev, (void*)buffer, 1);
      if(res==SD_OK)
      {
        // Some action here
      }
    }
  }
}

Important

About HW

I wanna make a comment about the CS line (chip select). If you use a SPI module
in your hardware don’t use the CS automatic capability. When you send a command
package to SD card (command and argument), we will need the CS line in
low-level all the time. If you use the CS automatic capability this logic will
be broken.
Also I strongly recommend uses a hardware timer associated with SPI_Timer
methods.

About license

This library was strongly inspired by elm-chang FatFs code.
In reddit they ask me about if the
library is inspired or derived from Chan work. Mister Chan hasn’t a SD library
formally, the code in general appear as API or sometime as a specific code to
the project that he works. I have many lines similar to Mister Chan code of
their SD driver. The spirit of this library is cover the semantics of SD cards
specifically. Now works with Cortex-M0/+, in a near future I hope write about
how work with 8-bit MCU successfully. Against any ambiguous interpretation I
think the correct license will be keep the original license used by Mister Chan
in the code of FatFS (BSD-style).

License

Unless indicated other license:

/*----------------------------------------------------------------------------/
/  ulibSD - Library for SD cards semantics            (C)Nelson Lombardo, 2015
/-----------------------------------------------------------------------------/
/ ulibSD library is a free software that opened under license policy of
/ following conditions.
/
/ Copyright (C) 2015, ChaN, all right reserved.
/
/ 1. Redistributions of source code must retain the above copyright notice,
/    this condition and the following disclaimer.
/
/ This software is provided by the copyright holder and contributors "AS IS"
/ and any warranties related to this software are DISCLAIMED.
/ The copyright owner or contributors be NOT LIABLE for any damages caused
/ by use of this software.
/----------------------------------------------------------------------------*/

// Derived from Mister Chan works on FatFs code (http://elm-chan.org/fsw/ff/00index_e.html):

/*----------------------------------------------------------------------------/
/  FatFs - FAT file system module  R0.11                 (C)ChaN, 2015
/-----------------------------------------------------------------------------/
/ FatFs module is a free software that opened under license policy of
/ following conditions.
/
/ Copyright (C) 2015, ChaN, all right reserved.
/
/ 1. Redistributions of source code must retain the above copyright notice,
/    this condition and the following disclaimer.
/
/ This software is provided by the copyright holder and contributors "AS IS"
/ and any warranties related to this software are DISCLAIMED.
/ The copyright owner or contributors be NOT LIABLE for any damages caused
/ by use of this software.
/----------------------------------------------------------------------------*/

Little and dirty script in Lua for web scraping in digikey

grab4eda It’s a pure-Lua script. Right now works on GNU/Linux only and the output is for use with Proteus/ISIS.

Example of use

Example of use

How to use:

  • Copy to /usr/bin
  • Give execute permissions
  • Execute grab4eda --create-config
  • Edit “~/.grab4eda/config” with your “strings”
  • Now, execute grab4eda with the product web link (digikey.com)
  • Is done! Enjoy.

Requisites

  • lua5.1
  • curl
  • xclip

Happy hacking!

Compiling MariaDB on Beaglebone Black

To compile MariaDB 10.0.16 on Debian GNU/Linux 7.8 (wheezy) at Beaglebone Black (based on “generic build instructions“):

  • Download the sources of MariaDB from here
  • You need install libncurses5-dev (“apt-get install libncurses5-dev”)
  • Also install cmake (“apt-get install cmake”)
  • Possibly you need a swap file, use this guide
  • Decompress the source of MariaDB and run “cmake -DWITHOUT_MROONGA_STORAGE_ENGINE=1″ to avoid this problem
  • If all it is ok run “make”, when it finish run “make install”
  • Prepare coffee and make some other stuff like biking or eat cookies :P
Screenshot of ssh on BBB showing Linux and MariaDB version

Screenshot of ssh on BBB showing Linux and MariaDB version

Happy Hacking ;)

How Long OLinuXino with Allwinner SOCs will be produced…again :) Now we know the answer – Forever!

Originally posted on olimex:

A10-OLinuXino-LIME-1

We already blogged twice about this: here and here, but you know what? People keep asking this question again and again.

Lot of serious customers are concerned about the long term availability of Allwinner SOCs before put them into their product.

Until now we didn’t know what to answer, to ask Allwinner (which is 5 years old company) if they will produce their SOC A10 for instance 10 years seems not good idea as in Chinese culture is known that they never will directly say no, and will tell you what you want to hear :)

Well now I know already how it works. We got message from Allwinner that A10 processor volumes now are low (for they normal volumes and this is understandable as no one is producing Tablets now with A10 when there is A20 at about same price and with more power). So Allwinner decide to…

View original 177 more words

Allwinner works on 64-bit Quad core Cortex-A53 SoC named Allwinner A64 to be released for $5

Originally posted on olimex:

Allwinner_A64

Just few months ago the only ARM 64-bit platform to test apps was iPhone6 and development boards with 64-bit processors cost $3000.

Now Allwinner announced that they will release entry level tablet Cortex-A53 Quad core processor for $5, this means there will be sub $100 development boards for ARM 64-bit as soon as Allwinner start selling these chips :)

Still no complete info about the features, Allwinner made practice to announce chips when they start working on them, not when they have them finished which is a bit annoying as these chips are released about year later (like the announcement for A80 one year ago).

No word for connectivity if this SOC will have SATA/Ethernet or will rely on USB3.0 as in Allwinner A80.

One more great news is that they finally decided to move to Linux 3.10 kernel and to start using device tree. This will make mainline Linux support…

View original 10 more words

Función para leer un archivo de propiedades en Lua/LuaJIT

A veces requerimos agregar la funcionalidad de parametrizar nuestro programa. En los sistemas UNIX’s estamos acostumbrados a encontrarnos con archivos de este estilo:

########################################################################
# Example #
########################################################################

msg = “Hello world!” # This string is correct
bad1 = Hello world!” # This string isn’t between two tokens
bad2 = Hello world! # The ” token is not present

trys = 1225 # This is a numeric configuration

pi = 3.1415 # Float
e = 2.71e-4 # Cientific notation
bad3 = 12c # The error is mix numbers and not valid text

number = 1 # If you repeat some parameter
number = 2 # the value that get is the last
number = 3 # appear in the file. In this case 3.

########################################################################
# End #
########################################################################

Eh creado un pequeños proyecto al cual llame LuaFRPF, una función que sirve para leer archivos de propiedades. La forma de usarla es muy sencilla y está explicada en la página.

Espero que les sirva.
Saludos.
Happy Hacking!

Xfce’s Drop Down Terminal

Originally posted on Techodyssey:

Screenshot - 011213 - 16:53:01As a followup to yesterday’s post on Tilda there is an alternative for Xfce users. The current Xfce terminal has a drop down option. However it is not obvious to most users.

It is a hidden option that applies to version 0.6.2 which is the standard version in Fedora 19. To access it you need to start the terminal with the command ‘xfce4-terminal –drop-down’. The man page gives more details and suggests you bind that command to a keyboard shortcut. That way you can press the key to open the terminal and pressing it again will hide but not close the terminal. This means there is no need to add it to your sessions or Autostart. The first time the key is pressed will launch and open it. Further presses will reveal or hide it.

I would suggest binding it to F12. To do this right click on the desktop…

View original 100 more words