<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="pl-pl">
<link rel="self" type="application/atom+xml" href="https://forum.atnel.pl/feed.php?f=18&amp;t=14465&amp;mode" />

<title>ATNEL tech-forum</title>
<link href="https://forum.atnel.pl/index.php" />
<updated>2016-02-09T23:31:22+01:00</updated>

<author><name><![CDATA[ATNEL tech-forum]]></name></author>
<id>https://forum.atnel.pl/feed.php?f=18&amp;t=14465&amp;mode</id>
<entry>
<author><name><![CDATA[atnelmaniak]]></name></author>
<updated>2016-02-09T23:31:22+01:00</updated>
<published>2016-02-09T23:31:22+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=14465&amp;p=153207#p153207</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=14465&amp;p=153207#p153207"/>
<title type="html"><![CDATA[Re: [POMOCY] MKBootloader + RS485]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=14465&amp;p=153207#p153207"><![CDATA[
Heh... Bootloader działa po rs232. Po rs485 info łapie od razu... Ale przy próbie wgrania mam tak, że wiesza się na uzupełnianiu strony i potem error... Jutro jeszcze włączę podsłuch i zobaczą co się przesyła. <br /><br />[syntax=c]Odczyt danych z BootLoader'a<br />Procesor: ATmega328p<br />Taktowanie: 16 000 000 Hz<br />BootLoader: 1<br />FLASH<br />PageSize: 128, FreeMEM: 32 256kb (0x7E00)<br />Uzupełnienie wsadu do pełnej strony PageSize<br />Wsad: 10 842 ----&gt; 10 880 bajtów<br />Błąd podczas programowania ! err: &#91;Timeout during operation&#93;  timeout=301[/syntax]<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=10486">atnelmaniak</a> — 9 lut 2016, o 23:31</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[jark]]></name></author>
<updated>2016-02-09T21:56:47+01:00</updated>
<published>2016-02-09T21:56:47+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=14465&amp;p=153200#p153200</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=14465&amp;p=153200#p153200"/>
<title type="html"><![CDATA[Re: [POMOCY] MKBootloader + RS485]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=14465&amp;p=153200#p153200"><![CDATA[
Witam.<br />Kod źródłowy bls z obsługą rs485 zrobiony na podstawie tego wątku:<br /><!-- l --><a class="postlink-local" href="http://forum.atnel.pl/topic2168.html" >topic2168.html</a><!-- l --><br /><br />[syntax=c]////////////////////////////////////////////////////////////////////////////////<br />/* Bootloader<br /> * Autor: Mirosław Kardaś (2009-06-16)<br /> * Modyfikacje: Paweł Szramowski (2009-06-30) */<br />////////////////////////////////////////////////////////////////////////////////<br /><br />////////////////////////////////////////////////////////////////////////////////<br />/* Dołączenie bibliotek */<br />////////////////////////////////////////////////////////////////////////////////<br /><br />/* biblioteki avr-libc */<br />#include &lt;stdint.h&gt;<br />#include &lt;avr/boot.h&gt;<br />#include &lt;avr/io.h&gt;<br />#include &lt;avr/pgmspace.h&gt;<br />#include &lt;avr/wdt.h&gt;<br />#include &lt;util/delay.h&gt;<br />#include &lt;util/setbaud.h&gt;<br /><br /><br />////////////////////////////////////////////////////////////////////////////////<br />/* Definicje stałych programowych i makr */<br />////////////////////////////////////////////////////////////////////////////////<br /><br />/* wersja bootloadera */<br />#define BOOTLOADER_VERSION 1<br /><br />/* ustawienia UART */<br />#define UART_DATA_BITS 8<br />#define UART_PARITY 'n'<br />#define UART_STOP_BITS 1<br />//#define USE_2X<br /><br /><br />// definicje na potrzeby RS485<br />#define UART_DE_PORT PORTD<br />#define UART_DE_DIR DDRD<br />#define UART_DE_BIT (1&lt;&lt;PD2)<br /><br />#define UART_DE_ODBIERANIE  UART_DE_PORT &amp;= ~UART_DE_BIT<br />#define UART_DE_NADAWANIE  UART_DE_PORT |= UART_DE_BIT<br /><br /><br /><br />/* dla procesorów typu ATmega88 gdy Watchdog działa także po resecie) itp trzeba włączyć poniższą opcję */<br />#define WDIFr<br /><br /><br /><br />/* czas przesyłania jednego znaku przez UART &#91;us&#93; */<br />#if UART_PARITY == 'n'<br />    #define UART_BYTE_TIME \<br />        ( 1000000UL / ( BAUD / ( 1 + UART_DATA_BITS + UART_STOP_BITS ) ) )<br />#elif ( UART_PARITY == 'e' ) || ( UART_PARITY == 'o' )<br />    #define UART_BYTE_TIME \<br />        ( 1000000UL / ( BAUD / ( 1 + UART_DATA_BITS + 1 + UART_STOP_BITS ) ) )<br />#endif<br /><br />/* podstawienie nazwa rejestrów UART */<br />#ifndef UCSRA<br />    #define UCSRA UCSR0A<br />#endif<br />#ifndef UCSRB<br />    #define UCSRB UCSR0B<br />#endif<br />#ifndef UCSRC<br />    #define UCSRC UCSR0C<br />#endif<br />#ifndef UBRRL<br />    #define UBRRL UBRR0L<br />#endif<br />#ifndef UBRRH<br />    #define UBRRH UBRR0H<br />#endif<br />#ifndef UDR<br />    #define UDR UDR0<br />#endif<br /><br />/* podstawienie nazw bitów w rejestrze UCSRA */<br />#ifndef RXC<br />    #define RXC RXC0<br />#endif<br />#ifndef TXC<br />    #define TXC TXC0<br />#endif<br />#ifndef UDRE<br />    #define UDRE UDRE0<br />#endif<br />#ifndef FE<br />    #define FE FE0<br />#endif<br />#ifndef DOR<br />    #define DOR DOR0<br />#endif<br />#ifndef UPE<br />    #define UPE UPE0<br />#endif<br />#ifndef U2X<br />    #define U2X U2X0<br />#endif<br />#ifndef MPCM<br />    #define MPCM MPCM0<br />#endif<br /><br />/* podstawienie nazw bitów w rejestrze UCSRB */<br />#ifndef RXCIE<br />    #define RXCIE RXCIE0<br />#endif<br />#ifndef TXCIE<br />    #define TXCIE TXCIE0<br />#endif<br />#ifndef UDRIE<br />    #define UDRIE UDRIE0<br />#endif<br />#ifndef RXEN<br />    #define RXEN RXEN0<br />#endif<br />#ifndef TXEN<br />    #define TXEN TXEN0<br />#endif<br />#ifndef UCSZ2<br />    #define UCSZ2 UCSZ02<br />#endif<br />#ifndef RXB8<br />    #define RXB8 RXB80<br />#endif<br />#ifndef TXB8<br />    #define TXB8 TXB80<br />#endif<br /><br />/* podstawienie nazw bitów w rejestrze UCSRC */<br />#ifdef URSEL0<br />       #define URSEL URSEL0<br />#endif       <br />#ifndef UMSEL<br />    #ifdef UMSEL0<br />        #define UMSEL UMSEL0<br />    #else<br />        #define UMSEL UMSEL00<br />        #define UMSEL0 UMSEL00<br />        #define UMSEL1 UMSEL01<br />    #endif<br />#endif<br />#ifndef UPM1<br />    #define UPM1 UPM01<br />#endif<br />#ifndef UPM0<br />    #define UPM0 UPM00<br />#endif<br />#ifndef USBS<br />    #define USBS USBS0<br />#endif<br />#ifndef UCSZ1<br />    #define UCSZ1 UCSZ01<br />#endif<br />#ifndef UCSZ0<br />    #define UCSZ0 UCSZ00<br />#endif<br />#ifndef UCPOL<br />    #define UCPOL UCPOL0<br />#endif<br /><br />#if UART_DATA_BITS == 5<br />    #define UCSRB_DATA_BITS ( 0 &lt;&lt; UCSZ2 )<br />    #define UCSRC_DATA_BITS ( 0 &lt;&lt; UCSZ1 | 0 &lt;&lt; UCSZ0 )<br />#elif UART_DATA_BITS == 6<br />    #define UCSRB_DATA_BITS ( 0 &lt;&lt; UCSZ2 )<br />    #define UCSRC_DATA_BITS ( 0 &lt;&lt; UCSZ1 | 1 &lt;&lt; UCSZ0 )<br />#elif UART_DATA_BITS == 7<br />    #define UCSRB_DATA_BITS ( 0 &lt;&lt; UCSZ2 )<br />    #define UCSRC_DATA_BITS ( 1 &lt;&lt; UCSZ1 | 0 &lt;&lt; UCSZ0 )<br />#elif UART_DATA_BITS == 8<br />    #define UCSRB_DATA_BITS ( 0 &lt;&lt; UCSZ2 )<br />    #define UCSRC_DATA_BITS ( 1 &lt;&lt; UCSZ1 | 1 &lt;&lt; UCSZ0 )<br />#elif UART_DATA_BITS == 9<br />    #define UCSRB_DATA_BITS ( 1 &lt;&lt; UCSZ2 )<br />    #define UCSRC_DATA_BITS ( 1 &lt;&lt; UCSZ1 | 1 &lt;&lt; UCSZ0 )<br />#endif<br /><br />#if UART_PARITY == 'n'<br />    #define UCSRC_PARITY ( 0 &lt;&lt; UPM1 | 0 &lt;&lt; UPM0 )<br />#elif UART_PARITY == 'e'<br />    #define UCSRC_PARITY ( 1 &lt;&lt; UPM1 | 0 &lt;&lt; UPM0 )<br />#elif UART_PARITY == 'o'<br />    #define UCSRC_PARITY ( 1 &lt;&lt; UPM1 | 1 &lt;&lt; UPM0 )<br />#endif<br /><br />#if UART_STOP_BITS == 1<br />    #define UCSRC_STOP_BITS ( 0 &lt;&lt; USBS )<br />#elif UART_STOP_BITS == 2<br />    #define UCSRC_STOP_BITS ( 1 &lt;&lt; USBS )<br />#endif<br /><br />/* makro zamieniające podany argument na łańcuch znaków */<br />#define TOSTRING( x ) STRINGIFY( x )<br />#define STRINGIFY( x ) #x<br /><br />////////////////////////////////////////////////////////////////////////////////<br />/* Deklaracje funkcji statycznych */<br />////////////////////////////////////////////////////////////////////////////////<br /><br />static void UART_TX_Byte(<br />    const uint8_t Data );<br /><br />static void UART_TX_String_P(<br />    const prog_char *String_Ptr );<br /><br />static uint8_t _UART_RX_Wait(<br />    uint16_t Timeout );<br /><br />/* Makro przeliczające argument w milisekundach na przyjmowaną przez funkcję <br /> * _UART_RX_Wait wielokrotność czasu przesyłania jednego znaku. */<br />#define UART_RX_Wait( x ) _UART_RX_Wait( ( x * 1000UL ) / UART_BYTE_TIME )<br /><br />////////////////////////////////////////////////////////////////////////////////<br />/* Definicje funkcji */<br />////////////////////////////////////////////////////////////////////////////////<br /><br />static void __vectors( <br />    void )<br />    __attribute__ (( section( &quot;.vectors&quot; ), naked, used ));<br />static void __vectors( <br />    void )<br />{<br />    /* skok do sekcji .init2 (konieczny ze względu na umieszczanie stałych z <br />     * pamięci programu pomiędzy sekcjami .vectors a .init0, a więc na samym <br />     * początku programu w przypadku wykorzystania opcji -nostartfiles */<br />    asm (<br />        &quot;rjmp __init2&quot; &quot;\n\t&quot;<br />        : : );<br />}<br /><br />static void __init2( <br />    void )<br />    __attribute__ (( section( &quot;.init2&quot; ), naked, used ));<br />static void __init2( <br />    void )<br />{<br />    /* inicjalizacja wskaźnika stosu, rejestru z zerem i rejestru flag */<br />asm volatile (<br />&quot;out __SP_L__, %A0&quot; &quot;\n\t&quot;<br />&quot;out __SP_H__, %B0&quot; &quot;\n\t&quot;<br />&quot;clr __zero_reg__&quot; &quot;\n\t&quot;<br />&quot;out __SREG__, __zero_reg__&quot; &quot;\n\t&quot;<br />        : : &quot;r&quot;( ( uint16_t )( RAMEND ) ) );<br />}<br /><br /><br /><br /><br />#ifdef WDIFr<br />    static void __init3( <br />        void )<br />        __attribute__ (( section( &quot;.init3&quot; ), naked, used ));<br />    static void __init3( <br />        void )<br />    {<br />        /* wyłączenie watchdoga (w tych mikrokontrolerach, w których watchdog <br />         * ma możliwość generowania przerwania pozostaje on też aktywny po <br />         * resecie) */<br />        MCUSR = 0;<br />        _WD_CONTROL_REG = 1 &lt;&lt; _WD_CHANGE_BIT | 1 &lt;&lt; WDE;<br />        _WD_CONTROL_REG = 0;<br />    }<br />#endif<br /><br />static void __init9( <br />    void )<br />    __attribute__ (( section( &quot;.init9&quot; ), naked, used ));<br />static void __init9( <br />    void )<br />{<br />    /* skok do funkcji main */<br />asm (<br />&quot;rjmp main&quot; &quot;\n\t&quot;<br />        : : );<br />}<br /><br /><br /><br /><br />int main( <br />    void )<br />    __attribute__ (( noreturn ));<br />int main( <br />    void )<br />{<br />    /* konfiguracja i włączenie interfejsu UART */<br />    UBRRH = UBRRH_VALUE;<br />    UBRRL = UBRRL_VALUE;<br />    #if USE_2X<br />        UCSRA = 1 &lt;&lt; U2X;<br />    #else<br />        UCSRA = 0;<br />    #endif<br />    #ifdef URSEL<br />        UCSRC = 1 &lt;&lt; URSEL | UCSRC_DATA_BITS | UCSRC_PARITY | UCSRC_STOP_BITS;<br />    #else<br />         #ifdef URSEL0  /* opcja specjalna dla ATmega162 */<br />             UCSRC = 1 &lt;&lt; URSEL0 | UCSRC_DATA_BITS | UCSRC_PARITY | UCSRC_STOP_BITS;<br />         #else<br />             UCSRC = UCSRC_DATA_BITS | UCSRC_PARITY | UCSRC_STOP_BITS;<br />         #endif<br />    #endif<br />    UCSRB = 1 &lt;&lt; RXEN | 1 &lt;&lt; TXEN | UCSRB_DATA_BITS;<br />    <br />    /* deklaracja zmiennych */<br />    uint8_t Received_Char;<br />UART_DE_DIR |= UART_DE_BIT;<br />UART_DE_ODBIERANIE;    <br />    /* wysyłanie znaku '?' do odebrania znaku 'u' lub upłynięcia czasu <br />     * oczekiwania */<br />for ( uint8_t Retries_Left = BOOT_WAIT * 10; Retries_Left &gt; 0; <br />        --Retries_Left )<br />{<br />        if ( ( Received_Char = UART_RX_Wait( 100 ) ) == 'u' )<br />            break;<br />        <br />UART_TX_Byte( '?' );<br />}<br /><br />    if ( Received_Char == 'u' )<br />    {<br />        while ( 1 )<br />        {<br />            /* odebranie znaku */<br />            Received_Char = UART_RX_Wait( 1000 );<br />            <br />            if ( Received_Char == 'i' )<br />            {<br />                /* jeśli odebrano znak 'i', to wysłanie ciągu znaków <br />                 * identyfikujących mikrokontroler i bootloader */<br />                UART_TX_String_P( PSTR( &quot;\r\n&quot; &quot;&amp;&quot; <br />                    TOSTRING( SPM_PAGESIZE ) &quot;,&quot; <br />                    TOSTRING( BLS_START ) &quot;,&quot; <br />                    TOSTRING( MCU ) &quot;,&quot; <br />                    TOSTRING( XTAL ) &quot;,&quot; <br />                    TOSTRING( BOOTLOADER_VERSION )<br />                    &quot;*&quot; &quot;\r\n&quot; ) );<br />            }<br />            else if ( Received_Char == 'w' )<br />            {<br />                /* odczekanie do zakończenia operacji na pamięci EEPROM <br />                 * i Flash */<br />                eeprom_busy_wait();<br />                boot_spm_busy_wait();<br />                <br />                /* kasowanie całej pamięci programu */<br />                for ( uint32_t Page_Address = 0; Page_Address &lt; BLS_START; <br />                    Page_Address += SPM_PAGESIZE )<br />                {<br />                    /* skasowanie strony pamięci */<br />                    boot_page_erase( Page_Address );<br />                    boot_spm_busy_wait();<br />                }<br />                <br />                /* programowanie pamięci programu */<br />                for ( uint32_t Page_Address = 0; Page_Address &lt; BLS_START; <br />                    Page_Address += SPM_PAGESIZE )<br />                {<br />                    /* wysłanie znaku '@' */<br />                    UART_TX_Byte( '@' );<br />                    <br />                    /* jeśli odebrano zero lub upłynął czas oczekiwania na <br />                     * odpowiedź, to zakończenie pracy bootloadera */<br />                    if ( !UART_RX_Wait( 500 ) )<br />                        break;<br />                    <br />                    /* zapełnienie bufora strony */<br />                    for ( uint16_t Byte_Address = 0; <br />                        Byte_Address &lt; SPM_PAGESIZE; Byte_Address += 2 )<br />                    {<br />                        /* przygotowanie instrukcji */<br />                        uint16_t Instruction = ( uint16_t )UART_RX_Wait( 500 );<br />                        Instruction += UART_RX_Wait( 500 ) &lt;&lt; 8;<br />                        <br />                        /* zapisanie instrukcji do bufora */<br />                        boot_page_fill( Byte_Address, Instruction );<br />                    }<br />                    <br />                    /* zapisanie strony pamięci */<br />                    boot_page_write( Page_Address );<br />                    boot_spm_busy_wait();<br />                }<br />                <br />                /* odblokowanie sekcji Read-While-Write */<br />                boot_rww_enable();<br />                <br />                /* zakończenie pracy bootloadera */<br />                break;<br />            }<br />            else<br />            {<br />                /* jeśli odebrano inny znak lub upłynął czas oczekiwania na <br />                 * odpowiedź, to zakończenie pracy bootloadera */<br />                break;<br />            }<br />        }<br />    }<br />    <br />    /* wyłączenie interfejsu UART (dzieje się to dopiero po zakończeniu <br />     * wysyłania) i odczekanie do końca ewentualnej transmisji */<br />UCSRB = 0;<br />    //_delay_us( UART_BYTE_TIME );<br />    <br />    /* skok do właściwego programu */<br /><br />    #ifdef __AVR_HAVE_JMP_CALL__<br />        asm volatile ( <br />            &quot;jmp 0&quot; &quot;\n\t&quot;<br />            : : );<br />    #else<br />        asm volatile ( <br />            &quot;clr r30&quot; &quot;\n\t&quot;<br />            &quot;clr r31&quot; &quot;\n\t&quot;<br />            &quot;ijmp&quot; &quot;\n\t&quot;<br />            : : );<br />    #endif<br /><br />    <br />    /* nieskończona pętla (konieczna, by kompilator nie wygenerował <br />     * niepotrzebnego kodu) */<br />    while ( 1 )<br />        {}<br />}<br /><br />static void UART_TX_Byte(<br />    const uint8_t Data )<br />{<br />while ( !( UCSRA &amp; 1 &lt;&lt; UDRE ) ) wdt_reset();<br />        <br />    UART_DE_NADAWANIE;<br />UDR = Data;<br />while ( !( UCSRA &amp; 1 &lt;&lt; TXC ) ) wdt_reset();<br />UCSRA|=1&lt;&lt;TXC;<br />UART_DE_ODBIERANIE;<br /><br />}<br /><br />static void UART_TX_String_P(<br />    const prog_char *String_Ptr )<br />{<br />uint8_t Single_Char;<br />    <br />while ( ( Single_Char = pgm_read_byte( String_Ptr++ ) ) )<br />        UART_TX_Byte( Single_Char );<br />}<br /><br />static uint8_t _UART_RX_Wait( <br />    uint16_t Timeout )<br />{<br />do<br />    {<br />if ( UCSRA &amp; 1 &lt;&lt; RXC )<br />            return UDR;<br />        <br />        _delay_us( UART_BYTE_TIME );<br />} while ( Timeout-- );<br />    <br />return 0;<br />}[/syntax]<br /><br />+ makefile dla atmeg32.<br />[syntax=c]#----------------------------------------------------------------------------<br /># make all = Make software.<br /># make clean = Clean out built project files.<br /># make size = Display sizes of object files.<br /># make doc = Start doxygen to prepare documentation.<br /># make filename.s = Just compile filename.c into the assembler code only.<br /># make filename.i = Create a preprocessed source file.<br /># make program = Download the hex file to the device.<br /># make fuse = Download configuration bits to the device.<br /># make lock = Download lock bits to the device.<br />#----------------------------------------------------------------------------<br /><br /># MCU name<br />#MCU = atmega8<br />#MCU = atmega16<br />#MCU = atmega168<br />MCU = atmega32<br />#MCU = atmega644p<br /><br /># MCU frequency (without UL suffix)<br />F_CPU = 11059200<br />#F_CPU = 8000000<br />#F_CPU = 16000000<br /><br /># Bootloader options<br />#BLS_START = 0x1E00<br />#BLS_START = 0x3E00<br />BLS_START = 0x7E00<br />#BLS_START = 0xFC00<br />BOOT_WAIT = 2<br />BAUD_RATE = 19200<br />#BAUD_RATE = 115200<br /><br /># MCU configuration fuse and lockbits (leave empty if not to be programmed or <br /># to be programmed according to .fuse and .lock sections in ELF file)<br />LFUSE = <br />HFUSE = <br />EFUSE = <br />LOCK = <br /><br /># Target file name (without extension)<br />TARGET = Bootloader<br /><br /># Optimization level (can be 0, 1, 2, 3 or s)<br />OPT = s<br /><br /># List C source files here (C dependencies are automatically generated)<br />SRC = main.c<br /><br /># List Assembler source files here (make them always end in a capital .S!)<br />ASRC = <br /><br /># List any extra directories to look for include files here<br />EXTRAINCDIRS =<br /><br /># Doxygen configuration file (leave empty if not available)<br />DOXYFILE = <br /><br /># C Standard level (can be c89, gnu89, c99 or gnu99)<br />CSTANDARD = -std=gnu99<br /><br /># Output format (can be srec, ihex or binary)<br />FORMAT = ihex<br /><br /># Debugging format<br />DEBUG = dwarf-2<br /><br /># Programming hardware<br />AVRDUDE_PROGRAMMER = usbasp<br />AVRDUDE_PORT = lpt1<br /><br /># Object files directory (don't leave it empty, put . instead!)<br />OBJDIR = .<br /><br /># Place -D or -U options here for all sources<br />COMDEFS = -DBLS_START=$(BLS_START)<br />COMDEFS += -DBOOT_WAIT=$(BOOT_WAIT)<br />COMDEFS += -DBAUD=$(BAUD_RATE)<br />COMDEFS += -DXTAL=$(F_CPU) <br />COMDEFS += -DMCU=$(MCU) <br /><br /># Place -D or -U options here for C sources<br />CDEFS = <br /><br /># Place -D or -U options here for ASM sources<br />ADEFS = <br /><br /><br />#---------------- Compiler Options C ----------------<br />#  -g*:          generate debugging information<br />#  -O*:          optimization level<br />#  -f...:        tuning, see GCC manual and avr-libc documentation<br />#  -Wall...:     warning level<br />#  -Wa,...:      tell GCC to pass this to the assembler.<br />#    -adhlns...: create assembler listing<br />CFLAGS = -g$(DEBUG)<br />CFLAGS += -DF_CPU=$(F_CPU)UL<br />CFLAGS += $(COMDEFS)<br />CFLAGS += $(CDEFS)<br />CFLAGS += -O$(OPT)<br />CFLAGS += -fgnu89-inline<br />CFLAGS += -funsigned-char<br />CFLAGS += -funsigned-bitfields<br />CFLAGS += -fpack-struct<br />CFLAGS += -fshort-enums<br />CFLAGS += -fno-tree-scev-cprop<br />CFLAGS += -fno-inline-small-functions<br />CFLAGS += -fno-split-wide-types<br />CFLAGS += -ffreestanding<br />CFLAGS += -mno-interrupts<br />#CFLAGS += -mshort-calls<br />CFLAGS += -pedantic<br />CFLAGS += -Wextra<br />CFLAGS += -Wno-sign-compare<br />CFLAGS += -Wstrict-prototypes<br />CFLAGS += -Wundef<br />#CFLAGS += -Wunreachable-code<br />CFLAGS += -Wa,-adhlns=$(&lt;:%.c=$(OBJDIR)/%.lst)<br />CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))<br />CFLAGS += $(CSTANDARD)<br />CFLAGS += -Wno-deprecated-declarations -D__PROG_TYPES_COMPAT__<br /><br />#---------------- Assembler Options ----------------<br />#  -Wa,...:   tell GCC to pass this to the assembler.<br />#  -adhlns:   create listing<br />#  -gstabs:   have the assembler create line number information; note that<br />#             for use in COFF files, additional information about filenames<br />#             and function names needs to be present in the assembler source<br />#             files -- see avr-libc docs &#91;FIXME: not yet described there&#93;<br />#  -listing-cont-lines: Sets the maximum number of continuation lines of hex<br />#       dump that will be displayed for a given single line of source input.<br />ASFLAGS = -gstabs<br />ASFLAGS += -DF_CPU=$(F_CPU)<br />ASFLAGS += $(COMDEFS)<br />ASFLAGS += $(ADEFS)<br />ASFLAGS += -Wa,-adhlns=$(&lt;:%.S=$(OBJDIR)/%.lst)<br />ASFLAGS += -listing-cont-lines=100<br /><br /><br />#---------------- Library Options ----------------<br /># List any extra directories to look for libraries here.<br />#     Each directory must be seperated by a space.<br />#     Use forward slashes for directory separators.<br />#     For a directory that has spaces, enclose it in quotes.<br />EXTRALIBDIRS =<br /><br /><br />#---------------- Linker Options ----------------<br />#  -Wl,...:     tell GCC to pass this to linker.<br />#    -Map:      create map file<br />#    --cref:    add cross reference to  map file<br />LDFLAGS = -Wl,-Map=$(TARGET).map,--cref<br />#LDFLAGS += -Wl,--relax<br />LDFLAGS += -nostartfiles<br />LDFLAGS += -Wl,--section-start=.text=$(BLS_START)<br />LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))<br />#LDFLAGS += -T linker_script.x<br /><br /><br />#---------------- Programming Options (avrdude) ----------------<br />AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER)<br /><br /><br />#============================================================================<br /><br /><br /># Define programs and commands.<br />SHELL = sh<br />CC = avr-gcc<br />OBJCOPY = avr-objcopy<br />OBJDUMP = avr-objdump<br />SIZE = avr-size<br />AR = avr-ar rcs<br />NM = avr-nm<br />AVRDUDE = avrdude<br />REMOVE = rm -f<br />REMOVEDIR = rm -rf<br />COPY = cp<br />WINSHELL = cmd<br />DOXYGEN = doxygen<br /><br /><br /># Define all object files.<br />OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)<br /><br /># Define all listing files.<br />LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)<br /><br /><br /># Compiler flags to generate dependency files.<br />GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d<br /><br /><br /># Combine all necessary flags and optional flags.<br /># Add target processor to flags.<br />ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS)<br />ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)<br /><br /><br />#============================================================================<br /><br /><br /># Default target.<br />all: begin sizebefore build sizeafter end<br /><br /># Change the build target to build a HEX file or a library.<br />build: elf hex lss sym<br />#build: lib<br /><br /><br />burn: fuse program lock<br /><br />elf: $(TARGET).elf<br />hex: $(TARGET).hex<br />lss: $(TARGET).lss<br />sym: $(TARGET).sym<br />LIBNAME=lib$(TARGET).a<br />lib: $(LIBNAME)<br /><br /><br /># Eye candy.<br />begin:<br />@echo<br />@echo -------- begin --------<br /><br />end:<br />@echo --------  end  --------<br />@echo<br /><br /><br /># Display size of file.<br />HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex<br />ELFSIZE = $(SIZE) --mcu=$(MCU) --format=avr $(TARGET).elf<br /><br />sizebefore:<br />@if test -f $(TARGET).elf; then echo; echo Size before:; $(ELFSIZE); \<br />2&gt;/dev/null; fi<br /><br />sizeafter:<br />@if test -f $(TARGET).elf; then echo; echo Size after:; $(ELFSIZE); \<br />2&gt;/dev/null; fi<br /><br /><br /># Program the device.<br />program: $(TARGET).hex<br />@echo<br />@echo Programming Flash memory:<br />$(AVRDUDE) $(AVRDUDE_FLAGS) -U flash:w:$(TARGET).hex<br /><br /><br /># Program fusebits.<br />fuse: $(TARGET).elf<br />@echo<br />ifdef LFUSE<br />@echo Programming low fusebits:<br />$(AVRDUDE) $(AVRDUDE_FLAGS) -U lfuse:w:$(LFUSE):m<br />else<br />@echo Creating load file for low fusebits:<br />-$(OBJCOPY) -j .fuse --change-section-lma .fuse=0 --no-change-warnings \<br />-i 3 -b 0 -O $(FORMAT) $&lt; $(TARGET).lfuse || exit 0<br />@echo<br />@echo Programming low fusebits:<br />$(AVRDUDE) $(AVRDUDE_FLAGS) -U lfuse:w:$(TARGET).lfuse    <br />endif<br />@echo<br />ifdef HFUSE<br />@echo Programming high fusebits:<br />$(AVRDUDE) $(AVRDUDE_FLAGS) -U hfuse:w:$(HFUSE):m<br />else<br />@echo Creating load file for high fusebits:<br />-$(OBJCOPY) -j .fuse --change-section-lma .fuse=0 --no-change-warnings \<br />-i 3 -b 1 -O $(FORMAT) $&lt; $(TARGET).hfuse || exit 0<br />@echo<br />@echo Programming high fusebits:<br />$(AVRDUDE) $(AVRDUDE_FLAGS) -U hfuse:w:$(TARGET).hfuse    <br />endif<br />@echo<br />ifdef EFUSE<br />@echo Programming extended fusebits:<br />$(AVRDUDE) $(AVRDUDE_FLAGS) -U efuse:w:$(EFUSE):m<br />else<br />@echo Creating load file for extended fusebits:<br />-$(OBJCOPY) -j .fuse --change-section-lma .fuse=0 --no-change-warnings \<br />-i 3 -b 2 -O $(FORMAT) $&lt; $(TARGET).efuse || exit 0<br />@echo<br />@echo Programming extended fusebits:<br />$(AVRDUDE) $(AVRDUDE_FLAGS) -U efuse:w:$(TARGET).efuse    <br />endif<br /><br /><br /># Program lockbits.<br />lock: $(TARGET).elf<br />@echo<br />ifdef LOCK<br />@echo Programming lockbits:<br />$(AVRDUDE) $(AVRDUDE_FLAGS) -U lock:w:$(LOCK):m<br />else<br />@echo Creating load file for lockbits:<br />-$(OBJCOPY) -j .lock --change-section-lma .lock=0 --no-change-warnings \<br />-O $(FORMAT) $&lt; $(TARGET).lock || exit 0<br />@echo<br />@echo Programming lockbits:<br />$(AVRDUDE) $(AVRDUDE_FLAGS) -U lock:w:$(TARGET).lock<br />endif<br /><br /><br /># Generate documentation with Doxygen.<br />doc:<br />@if test -f $(DOXYFILE); echo; then $(DOXYGEN) $(DOXYFILE); fi<br /><br /><br /># Display sizes of the object files.<br />size: $(OBJ)<br />@echo<br />@echo Sizes of the object files &quot;(Flash = .text + .data, RAM = .data + .bss)&quot;:<br />$(SIZE) -B -d -t --common $(OBJ)<br /><br /><br /># Create final output file (.hex) from ELF output file.<br />%.hex: %.elf<br />@echo<br />@echo Creating load file for Flash: $@<br />$(OBJCOPY) -O $(FORMAT) -R .eeprom -R .fuse -R .lock $&lt; $@<br /><br /># Create extended listing file from ELF output file.<br />%.lss: %.elf<br />@echo<br />@echo Creating Extended Listing: $@<br />$(OBJDUMP) -h -S -z $&lt; &gt; $@<br /><br /># Create a symbol table from ELF output file.<br />%.sym: %.elf<br />@echo<br />@echo Creating Symbol Table: $@<br />$(NM) -n $&lt; &gt; $@<br /><br /><br /># Create library from object files.<br />.SECONDARY : $(TARGET).a<br />.PRECIOUS : $(OBJ)<br />%.a: $(OBJ)<br />@echo<br />@echo Creating library: $@<br />$(AR) $@ $(OBJ)<br /><br /><br /># Link: create ELF output file from object files.<br />.SECONDARY : $(TARGET).elf<br />.PRECIOUS : $(OBJ)<br />%.elf: $(OBJ)<br />@echo<br />@echo Linking: $@<br />$(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS)<br /><br /><br /># Compile: create object files from C source files.<br />$(OBJDIR)/%.o : %.c<br />@echo<br />@echo Compiling C: $&lt;<br />$(CC) -c $(ALL_CFLAGS) $&lt; -o $@<br /><br /><br /># Compile: create assembler files from C source files.<br />%.s : %.c<br />$(CC) -S $(ALL_CFLAGS) $&lt; -o $@<br /><br /><br /># Assemble: create object files from assembler source files.<br />$(OBJDIR)/%.o : %.S<br />@echo<br />@echo Assembling: $&lt;<br />$(CC) -c $(ALL_ASFLAGS) $&lt; -o $@<br /><br /><br /># Create preprocessed source for use in sending a bug report.<br />%.i : %.c<br />$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $&lt; -o $@<br /><br /><br /># Target: clean project.<br />clean: begin clean_list end<br /><br />clean_list :<br />@echo<br />@echo Cleaning project:<br />$(REMOVE) $(TARGET).hex<br />$(REMOVE) $(TARGET).lfuse<br />$(REMOVE) $(TARGET).hfuse<br />$(REMOVE) $(TARGET).efuse<br />$(REMOVE) $(TARGET).lock<br />$(REMOVE) $(TARGET).elf<br />$(REMOVE) $(TARGET).map<br />$(REMOVE) $(TARGET).sym<br />$(REMOVE) $(TARGET).lss<br />$(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o)<br />$(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst)<br />$(REMOVE) $(ASRC:%.S=$(OBJDIR)/%.o)<br />$(REMOVE) $(ASRC:%.S=$(OBJDIR)/%.lst)<br />$(REMOVE) $(SRC:.c=.s)<br />$(REMOVE) $(SRC:.c=.d)<br />$(REMOVE) $(SRC:.c=.i)<br />$(REMOVEDIR) .dep<br /><br /><br /># Create object files directory<br />$(shell mkdir $(OBJDIR) 2&gt;/dev/null)<br /><br /><br /># Include the dependency files.<br />-include $(shell mkdir .dep 2&gt;/dev/null) $(wildcard .dep/*)<br /><br /><br /># Listing of phony targets.<br />.PHONY : all begin finish end sizebefore sizeafter \<br />build elf hex lss sym  \<br />clean clean_list program fuse lock doc[/syntax]<br /><br /> Na tym działa na 100% <img src="https://forum.atnel.pl/images/smilies/icon_e_smile.gif" alt=":)" title="Szczęśliwy" /><br />Pozdrawiam<br />Jarek<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=582">jark</a> — 9 lut 2016, o 21:56</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[atnelmaniak]]></name></author>
<updated>2016-02-09T09:31:47+01:00</updated>
<published>2016-02-09T09:31:47+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=14465&amp;p=153142#p153142</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=14465&amp;p=153142#p153142"/>
<title type="html"><![CDATA[Re: [POMOCY] MKBootloader + RS485]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=14465&amp;p=153142#p153142"><![CDATA[
Straciłem modyfikacją dla rs485. Jak próbuję ją sam napisać, to wywala mi błąd odczytu bls, odpowiada na co któreś info o procku, zaprogramować się nie daje. Ten sam wsad po rs232 śmiga, tak więc już nie wiem.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=10486">atnelmaniak</a> — 9 lut 2016, o 09:31</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[majster]]></name></author>
<updated>2016-02-09T07:34:52+01:00</updated>
<published>2016-02-09T07:34:52+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=14465&amp;p=153132#p153132</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=14465&amp;p=153132#p153132"/>
<title type="html"><![CDATA[Re: [POMOCY] MKBootloader + RS485]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=14465&amp;p=153132#p153132"><![CDATA[
Kolego a co to za problem ?<br /><br />Program mkbootloader generuje bls jak i wgrywa wsad.<br /><br />Jak straciles program i licencje to skontaktuj sie z Mirkiem.<br /><br />Namazane ze smarta.<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=1628">majster</a> — 9 lut 2016, o 07:34</p><hr />
]]></content>
</entry>
<entry>
<author><name><![CDATA[atnelmaniak]]></name></author>
<updated>2016-02-08T23:34:40+01:00</updated>
<published>2016-02-08T23:34:40+01:00</published>
<id>https://forum.atnel.pl/viewtopic.php?t=14465&amp;p=153123#p153123</id>
<link href="https://forum.atnel.pl/viewtopic.php?t=14465&amp;p=153123#p153123"/>
<title type="html"><![CDATA[[POMOCY] MKBootloader + RS485]]></title>

<content type="html" xml:base="https://forum.atnel.pl/viewtopic.php?t=14465&amp;p=153123#p153123"><![CDATA[
Dostałem swojego czasu świetnie działający bootloader naszego Mirka w opcji rs485. Niestety po awarii kompa już go nie mam a w dodatku skasowałem sobie bootloader w procku (atmega328p) zwykłym bootloaderem. Próbuję odtworzyć teraz zmiany bazując na postach z forum, jednak osiągam taki efekt, że jest błąd odczytu bls. W terminalu układ odpowiada dobrze na &quot;ui&quot;, jednak nie zawsze. Po rs232 śmiga super.  Czy może któryś z Kolegów mógłby podzielić się sprawnym bootloaderem?<p>Statystyki: Napisane przez <a href="https://forum.atnel.pl/memberlist.php?mode=viewprofile&amp;u=10486">atnelmaniak</a> — 8 lut 2016, o 23:34</p><hr />
]]></content>
</entry>
</feed>