<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://arm.mini-box.com/index.php?action=history&amp;feed=atom&amp;title=Kernel_changes_for_custom_hardware</id>
	<title>Kernel changes for custom hardware - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://arm.mini-box.com/index.php?action=history&amp;feed=atom&amp;title=Kernel_changes_for_custom_hardware"/>
	<link rel="alternate" type="text/html" href="https://arm.mini-box.com/index.php?title=Kernel_changes_for_custom_hardware&amp;action=history"/>
	<updated>2026-05-13T10:54:58Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.9</generator>
	<entry>
		<id>https://arm.mini-box.com/index.php?title=Kernel_changes_for_custom_hardware&amp;diff=49&amp;oldid=prev</id>
		<title>Admin: Protected &quot;Kernel changes for custom hardware&quot; ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))</title>
		<link rel="alternate" type="text/html" href="https://arm.mini-box.com/index.php?title=Kernel_changes_for_custom_hardware&amp;diff=49&amp;oldid=prev"/>
		<updated>2020-10-19T18:50:29Z</updated>

		<summary type="html">&lt;p&gt;Protected &amp;quot;&lt;a href=&quot;/index.php/Kernel_changes_for_custom_hardware&quot; title=&quot;Kernel changes for custom hardware&quot;&gt;Kernel changes for custom hardware&lt;/a&gt;&amp;quot; ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite))&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left diff-editfont-monospace&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 18:50, 19 October 2020&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
	<entry>
		<id>https://arm.mini-box.com/index.php?title=Kernel_changes_for_custom_hardware&amp;diff=48&amp;oldid=prev</id>
		<title>Admin: Created page with &quot;&lt;h2&gt;Touchscreens&lt;/h2&gt;  *1. Resistive: No changes needed. *2. Capacitive: Transfer is made thru i2c and interrupt pin is AT91_PIN_PA27. Make sure you compile the proper support...&quot;</title>
		<link rel="alternate" type="text/html" href="https://arm.mini-box.com/index.php?title=Kernel_changes_for_custom_hardware&amp;diff=48&amp;oldid=prev"/>
		<updated>2020-10-19T18:50:14Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;lt;h2&amp;gt;Touchscreens&amp;lt;/h2&amp;gt;  *1. Resistive: No changes needed. *2. Capacitive: Transfer is made thru i2c and interrupt pin is AT91_PIN_PA27. Make sure you compile the proper support...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;h2&amp;gt;Touchscreens&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*1. Resistive: No changes needed.&lt;br /&gt;
*2. Capacitive: Transfer is made thru i2c and interrupt pin is AT91_PIN_PA27. Make sure you compile the proper support for your capacitive panel chip in kernel and you supply the proper interrupt pin to the driver.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;How to compile kernel for a 7&amp;quot; touchscreen&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
By defaults kernels are compiled for 4.3&amp;quot; LCD. For 7&amp;quot; you will need to compile a new kernel or use the kernel from Android 4.0 build and overwrite the kernel from Android 2.3 built for example.&lt;br /&gt;
If you want to compile a new kernel you wil have to add:&lt;br /&gt;
&lt;br /&gt;
#define PICOSAM9G45_BIG_DISPLAY [http://gitorious.org/picopc-kernel/kernel/blobs/minibox-picopc-android-3.1/arch/arm/mach-at91/board-picosam9g45.c#line206 here]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Using another LCD&amp;lt;/h2&amp;gt;&lt;br /&gt;
You will need to recompile the kernel and setup the monitor and resolution from our board definition files.&amp;lt;br&amp;gt;&lt;br /&gt;
To do this, follow this steps:&lt;br /&gt;
&lt;br /&gt;
*1. Download kernel and toolchain from our gitorious repository as explained on [[Kernel_Building|Kernel building]] page. &lt;br /&gt;
*2. Edit the file ''kernel/arch/arm/mach-at91/board-picosam9g45.c'' and change the struct:&amp;lt;br&amp;gt;&amp;quot;''fb_videomode at91_tft_vga_modes''&amp;quot; and &amp;quot;''fb_monspecs at91fb_default_monspecs''&amp;quot; to match your display configuration from the display datasheet.To understand translation between display datasheet naming and kernel read [[Linux_LCD_timing_handling_and_interfacing|here]]&lt;br /&gt;
*3. Recompile the kernel and put it on your microSD BOOT partition.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Adding a GPIO as a key in kernel &amp;lt;/h2&amp;gt;&lt;br /&gt;
*1. Edit ''arch/arm/mach-at91/board-picosam9g45.c'' and add on the struct ''struct gpio_keys_button picosam9g45_buttons[]'':&lt;br /&gt;
&lt;br /&gt;
       {       /* J14 USR2 pin 1 gnd + pin 6*/&lt;br /&gt;
               .code           = KEY_UP,&lt;br /&gt;
               .gpio           = AT91_PIN_PC20,&lt;br /&gt;
               .active_low     = 1,&lt;br /&gt;
               .desc           = &amp;quot;Up Arrow&amp;quot;,&lt;br /&gt;
       },&lt;br /&gt;
&lt;br /&gt;
The gpio-keys driver will automatically send KEY_UP event when USR2 pin is put to ground&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt; Adding a GPIO as a led in kernel &amp;lt;/h2&amp;gt;&lt;br /&gt;
*1. Edit ''arch/arm/mach-at91/board-picosam9g45.c'' and add on the struct ''struct gpio_led picosam9g45_leds[]'':&lt;br /&gt;
        {       /* &amp;quot;usr3&amp;quot; led */                                                                                                                                                                                                               &lt;br /&gt;
                .name                   = &amp;quot;usr3&amp;quot;,                                                                                                                                                                                              &lt;br /&gt;
                .gpio                   = AT91_PIN_PC21,                                                                                                                                                                                      &lt;br /&gt;
                .active_low             = 1,                                                                                                                                                                                                 &lt;br /&gt;
                .default_trigger        = &amp;quot;none&amp;quot;,                                                                                                                                                                                            &lt;br /&gt;
        },&lt;br /&gt;
&lt;br /&gt;
The led can be controlled by writing 0 or 1 to ''/sys/class/leds/usr3''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Working with GPIOs&amp;lt;/h2&amp;gt;&lt;br /&gt;
For GPIOs that aren't bound in kernel to a device/key/led, you can control them from ''sysfs'' interface from ''/sys/class/gpio/''&amp;lt;br&amp;gt;&lt;br /&gt;
There you have multiple gpiochip&amp;lt;nnn&amp;gt; each corresponding to the A,B,C,D,E peripheals.&amp;lt;br&amp;gt;&lt;br /&gt;
For example PC is gpiochip96&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To export PC19 (which you will find it as USR1 on J14 pin 5) do: &lt;br /&gt;
 echo &amp;quot;115&amp;quot; &amp;gt; export&lt;br /&gt;
&lt;br /&gt;
which means 96+19.&lt;br /&gt;
&lt;br /&gt;
a directory will appear in /sys/class/gpio/gpio115/ with 2 files (direction and value)&lt;br /&gt;
 echo out &amp;gt; direction&lt;br /&gt;
 echo 0 &amp;gt; value&lt;br /&gt;
&lt;br /&gt;
To set output of GPIO to 0&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example setting a GPIO as input&lt;br /&gt;
&lt;br /&gt;
  cd /sys/class/gpio/&lt;br /&gt;
  echo &amp;quot;115&amp;quot; &amp;gt; /sys/class/gpio/export&lt;br /&gt;
  cd /sys/class/gpio/gpio115/&lt;br /&gt;
  echo in &amp;gt; direction&lt;br /&gt;
  cat value&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Working with Analog-to-Digital Converter (ADC)&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The ADC in picoSAM9G45 board provides 7 channels. 3 of these are used for &lt;br /&gt;
the resistive touchscreen, the rest of 4 channels (available through J16) have a 10-bit resolution and &lt;br /&gt;
can be used to perform analog to digital conversions.&lt;br /&gt;
&lt;br /&gt;
The kernel will provide the following files to read values from the each &lt;br /&gt;
ADC channel (note that this functionality is not yet in the releases images see [https://gitorious.org/picopc-kernel/kernel/commit/eb3afc5d044b384b4f2204a1cca3ab2f1298e793 atmel_adc])&lt;br /&gt;
&lt;br /&gt;
  /sys/devices/platform/atmel_adc/ani0&lt;br /&gt;
  /sys/devices/platform/atmel_adc/ani1&lt;br /&gt;
  /sys/devices/platform/atmel_adc/ani2&lt;br /&gt;
  /sys/devices/platform/atmel_adc/ani3&lt;br /&gt;
&lt;br /&gt;
How to read and interpret the values:&lt;br /&gt;
&lt;br /&gt;
   cat /sys/devices/platform/atmel_adc/ani0 &lt;br /&gt;
&lt;br /&gt;
should output an integer value, that will need to be scaled as:&lt;br /&gt;
(ani value) * max voltage range / bit resolution.&lt;br /&gt;
&lt;br /&gt;
For ani0 and ani1 (voltage in 0V-50V range): (ani0 value) * 50/1023 &amp;lt;br&amp;gt;&lt;br /&gt;
For ani2 and ani3 (voltage in 0V-5V range): (ani2 value) * 5 /1023&lt;br /&gt;
&lt;br /&gt;
Note: The value for ani0 will always be the voltage that powers the picoSAM9G45 board.&lt;br /&gt;
&lt;br /&gt;
The reads are rate limited to work concurrently with the resistive touchscreen. &lt;br /&gt;
If a resistive touchscreen is not used the rate limit can be disabled by editing the&lt;br /&gt;
driver source code.&lt;br /&gt;
&lt;br /&gt;
'''J16 connector''' from pico-SAM9G45 board.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;dispayl: block; float: left; text-align: center; width: 30px; margin-top: 5px; padding: 0px; border:0px;&amp;quot;&amp;gt;http://arm.mini-box.com/images/J16-connector.jpg&amp;lt;br&amp;gt;GND&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;dispayl: block; float: left; text-align: center; width: 30px; margin-top: 5px; padding: 0px; border:0px;&amp;quot;&amp;gt;http://arm.mini-box.com/images/J16-connector.jpg&amp;lt;br&amp;gt;ani0&amp;lt;br&amp;gt;Vin&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;dispayl: block; float: left; text-align: center; width: 30px; margin-top: 5px; padding: 0px; border:0px;&amp;quot;&amp;gt;http://arm.mini-box.com/images/J16-connector.jpg&amp;lt;br&amp;gt;ani1&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;dispayl: block; float: left; text-align: center; width: 30px; margin-top: 5px; padding: 0px; border:0px;&amp;quot;&amp;gt;http://arm.mini-box.com/images/J16-connector.jpg&amp;lt;br&amp;gt;ani2&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;span style=&amp;quot;dispayl: block; float: left; text-align: center; width: 30px; margin-top: 5px; padding: 0px; border:0px;&amp;quot;&amp;gt;http://arm.mini-box.com/images/J16-connector.jpg&amp;lt;br&amp;gt;ani3&amp;lt;/span&amp;gt;&lt;br /&gt;
&amp;lt;div style=&amp;quot;clear: both;&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Power cycle/Reset miniPCI-E cards or USB devices&amp;lt;/h2&amp;gt;&lt;br /&gt;
Some miniPCI-E cards might not work after power-on. To fix this issue a software &amp;quot;reset&amp;quot; is needed:&lt;br /&gt;
&lt;br /&gt;
  cd /sys/bus/usb/devices&lt;br /&gt;
  ls -l&lt;br /&gt;
&lt;br /&gt;
Notice the folders with 1-2, 2-2 etc, to identify the product do:&lt;br /&gt;
  cat 1-2/product &lt;br /&gt;
and repeat for all folders till you identify the card&lt;br /&gt;
&lt;br /&gt;
To reset issue:&lt;br /&gt;
  echo 0 &amp;gt; 1-2/authorized&lt;br /&gt;
  echo 1 &amp;gt; 1-2/authorized&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Working with SPI interface&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
SPI interface can be accessed from userspace through spidev kernel driver.&amp;lt;br&amp;gt;&lt;br /&gt;
As of 12 Oct 2011 the spidev is included in [[Releases|binary releases]].&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
By default the SPI devices from [[J7 connector|J7 Connector] and [[J9 Connector|J9 Connector] (SPI0.0 and SPI1.0) are bound to this spidev driver.&amp;lt;br&amp;gt;&lt;br /&gt;
If you need to bound a spi device to another kernel driver edit ''arch/arm/mach-at91/board-picosam9g45.c'' around line 135 (SPI devices) and change ''.modalias'' to your driver name.&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
For testing [https://gitorious.org/picopc-tools/picopc-tools/blobs/master/hardware-tools/spi-test/ spidev_test] can be used.&amp;lt;br&amp;gt;&lt;br /&gt;
A sample output is:&lt;br /&gt;
&lt;br /&gt;
 root@picosam9:~# /spidev_test -s 14814814 -D /dev/spidev0.0&lt;br /&gt;
 spi mode: 0&lt;br /&gt;
 bits per word: 8&lt;br /&gt;
 max speed: 14814814 Hz (14814 KHz)&lt;br /&gt;
 00 00 00 00 00 00 &lt;br /&gt;
 00 00 00 00 00 00 &lt;br /&gt;
 00 00 00 00 00 00 &lt;br /&gt;
 00 00 00 00 00 00 &lt;br /&gt;
 00 00 00 00 00 00 &lt;br /&gt;
 00 00 00 00 00 00 &lt;br /&gt;
 00 00 &lt;br /&gt;
&lt;br /&gt;
''/dev/spidev0.0'' means the spi device on bus 0 chipselect 0 (SPI0 SPI0_CS0 in schematics for [[J7 connector|J7 connector]])&lt;br /&gt;
&amp;lt;h2&amp;gt;Working with I²C interface&amp;lt;/h2&amp;gt;&lt;br /&gt;
&lt;br /&gt;
I²C interface can be accessed from userspace through [http://www.kernel.org/doc/Documentation/i2c/dev-interface i2c-dev kernel driver].&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For testing i2c-dev communication [https://gitorious.org/picopc-tools/picopc-tools/trees/master/hardware-tools/qtouch-control qtouch-control] can be used as an example.&amp;lt;br&amp;gt;&lt;br /&gt;
More advanced tools can be found [http://www.lm-sensors.org/wiki/I2CTools here]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Using the buzzer&amp;lt;/h2&amp;gt;&lt;br /&gt;
You have to assign values between 0( which is no sound) to 255 to: &lt;br /&gt;
&lt;br /&gt;
  echo 200 &amp;gt; /sys/devices/platform/leds-atmel-pwm/leds/buzzer/brightness&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Change USART to RS-485 mode&amp;lt;/h2&amp;gt;&lt;br /&gt;
by user Minsc04 from [http://www.at91.com/forum/viewtopic.php/f%2c12/t%2c12783/ AT91SAM Community Forum]&amp;lt;br&amp;gt;&lt;br /&gt;
To change each USART in RS-485 mode, add this line in '''linux/drivers/serial/atmel_serial.c''' , in function '''atmel_set_termios''', just before the instruction &amp;quot;UART_PUT_MR(port, mode);&amp;quot; that configures the USART mode.&lt;br /&gt;
&lt;br /&gt;
 mode |= ATMEL_US_USMODE_RS485; //Take effect for all USART that you configure&lt;br /&gt;
&lt;br /&gt;
or if you want filter for a specific USART, use a dedicated IRQ number :&lt;br /&gt;
&lt;br /&gt;
 if (port-&amp;gt;irq == AT91SAM9260_ID_US2) // USART2 is a rs485&lt;br /&gt;
 {&lt;br /&gt;
 mode |= ATMEL_US_USMODE_RS485;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
&amp;lt;h2&amp;gt;Booting kernel from U-Boot&amp;lt;/h2&amp;gt;&lt;br /&gt;
*1. Disable direct kernel loading from bootstrap by changing DIRECT_BOOT to off in compile.sh. Reference commit in bootstrap: [https://gitorious.org/picopc-kernel/bootstrap-sdcard/commit/b1f4da58cc8feb977fb35535b46163488696652d Direct Kernel loading]&lt;br /&gt;
*2. It will expect uboot.bin actually be named linux.bin but that can be changed with FILE_NAME option in compile.sh.&lt;br /&gt;
*3. Use a Atmel patched uboot source from here: [http://www.at91.com/linux4sam/bin/view/Linux4SAM/U-Boot#U_boot_1_3_4_experimental_source uBoot for Atmel]&lt;br /&gt;
*4. Compile the sources with: make CROSS_COMPILE=&amp;lt;your toolchain location&amp;gt; at91sam9m10g45ek_config&lt;br /&gt;
*5. Optionally you can apply a patch to automatically enable 256Mb on picoPC.Patch is  [[File:0001-add-support-for-both-banks-of-memory-on-Atmel-G45-bo.patch]].&lt;br /&gt;
*6. Copy the newly compiled BOOT.BIN (from step 1), uboot.bin (from step 4) to microSD card BOOT partition (the FAT partition). The BOOT partition should contain: BOOT.BIN (the bootstrap) uboot.bin (uboot) uImage (the kernel in uimage format)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;h2&amp;gt;picoSAM9G45 board schematics&amp;lt;/h2&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
{{Schematics}}&lt;/div&gt;</summary>
		<author><name>Admin</name></author>
	</entry>
</feed>