问:
Issue with J-Link debugger while working with bootloader on STM32F765
I'm using the J-Link EDU and STLink debugger present on the Nucleo boards from ST. For testing, the bootloader code is present at 0x8000000 and just jumps to 0x8020000 where the main app code is present. When I use the Jlink EDU, it can't program the flash at 0x8020000 every time successfully and if I modify the program and start debugging, the Jlink erases the flash but does not program it successfully and after the bootloader makes the jump, the MCU gets HardFault. Now this happens whether I use Jlink or the STLINK (converted to Jlink). Usually I see it stuck at 0xFFFFFFFE. At that point the JLINK has erased the app code but failed to program it.

The interesting thing is that the STlink debugger when converted back and used with openocd has no issues whatsoever with the bootloader jumping to main app code and debugging from there.

I also find that if I program the main app code at 0x8020000 by STLink and OpenOCD and then switch to JLINK EDU for debug, it works as long as the JLINK does't reprogram it. If in the log, I see that the JLINK flashes the code, then the ST crashes after jumping from bootloader. So I definitely think it has something to do with how the JLINK is erasing and programming the ST during debug.

I also tried programming with JLINK commander and that seems to fail as well. Unless I fully erase the chip.

I'm using System Workbench 2.0 with GNU ARM Eclipse plugin for Jlink debugging with the latest ARM toolchain as of this date and Jlink 616c. I'm using the STM32F765VI with the flash in dual bank configuration.

I'm also attaching the GDB logs from JLINK and STLINK for clarity. I would like to use JLINK for debugging since I can have SWO console in eclipse whereas its very cumbersome in OpenOCD so would like to resolve it.

Failed JLINK debug after it tried to program:

```<code>SEGGER J-Link GDB Server V6.16c Command Line Version
JLinkARM.dll V6.16c (DLL compiled Jun 16 2017 18:14:49)

WARNING: Unknown command line parameter -timeout found.
WARNING: Unknown command line parameter 0 found.
-----GDB Server start settings-----
GDBInit file:                  none
GDB Server Listening port:     2331
SWO raw output listening port: 2332
Terminal I/O port:             2333
Accept remote connection:      localhost only
Generate logfile:              off
Verify download:               on
Init regs on start:            on
Silent mode:                   off
Single run mode:               on
Target connection timeout:     0 ms
------J-Link related settings------
J-Link Host interface:         USB
J-Link script:                 none
J-Link settings file:          none
------Target related settings------
Target device:                 STM32F765VI
Target interface:              SWD
Target interface speed:        1000kHz
Target endian:                 little

Connecting to J-Link...
J-Link is connected.
Firmware: J-Link V10 compiled Jun 16 2017 16:15:19
Hardware: V10.10
S/N: 260101191
OEM: SEGGER-EDU
Feature(s): FlashBP, GDB
Checking target voltage...
Target voltage: 3.35 V
Listening on TCP/IP port 2331
Connecting to target...Connected to target
Waiting for GDB connection...Connected to 127.0.0.1
Reading all registers
Read 4 bytes @ address 0x00000000 (Data = 0x51E9FF66)
Read 2 bytes @ address 0x00000000 (Data = 0xFF66)
Target interface speed set to 1000 kHz
Resetting target
Halting target CPU...
...Target halted (PC = 0x080023CC)
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000, R13= 20080000, MSP= 20080000, PSP= 00000000
R14(LR) = FFFFFFFF, R15(PC) = 080023CC
XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
Reading all registers
Read 4 bytes @ address 0x080023CC (Data = 0xD034F8DF)
Read 2 bytes @ address 0x080023CC (Data = 0xF8DF)
Target interface speed set to 15000 kHz
Flash breakpoints enabled
SWO disabled succesfully.
SWO enabled succesfully.
Read 4 bytes @ address 0x080023CC (Data = 0xD034F8DF)
Read 2 bytes @ address 0x080023CC (Data = 0xF8DF)
Downloading 520 bytes @ address 0x08020000 - Verified OK
Downloading 16064 bytes @ address 0x08020210 - Verified OK
Downloading 16096 bytes @ address 0x080240D0 - Verified OK
Downloading 16048 bytes @ address 0x08027FB0 - Verified OK
Downloading 16112 bytes @ address 0x0802BE60 - Verified OK
Downloading 16096 bytes @ address 0x0802FD50 - Verified OK
Downloading 16112 bytes @ address 0x08033C30 - Verified OK
Downloading 16144 bytes @ address 0x08037B20 - Verified OK
Downloading 16000 bytes @ address 0x0803BA30 - Verified OK
Downloading 15920 bytes @ address 0x0803F8B0 - Verified OK
Downloading 16176 bytes @ address 0x080436E0 - Verified OK
Downloading 16064 bytes @ address 0x08047610 - Verified OK
Downloading 16032 bytes @ address 0x0804B4D0 - Verified OK
Downloading 15696 bytes @ address 0x0804F370 - Verified OK
Downloading 16032 bytes @ address 0x080530C0 - Verified OK
Downloading 16176 bytes @ address 0x08056F60 - Verified OK
Downloading 16064 bytes @ address 0x0805AE90 - Verified OK
Downloading 16064 bytes @ address 0x0805ED50 - Verified OK
Downloading 16128 bytes @ address 0x08062C10 - Verified OK
Downloading 16176 bytes @ address 0x08066B10 - Verified OK
Downloading 16112 bytes @ address 0x0806AA40 - Verified OK
Downloading 16304 bytes @ address 0x0806E930 - Verified OK
Downloading 16272 bytes @ address 0x080728E0 - Verified OK
Downloading 16048 bytes @ address 0x08076870 - Verified OK
Downloading 16080 bytes @ address 0x0807A720 - Verified OK
Downloading 16048 bytes @ address 0x0807E5F0 - Verified OK
Downloading 16048 bytes @ address 0x080824A0 - Verified OK
Downloading 14616 bytes @ address 0x08086350 - Verified OK
Downloading 16144 bytes @ address 0x08089C80 - Verified OK
Downloading 16224 bytes @ address 0x0808DB90 - Verified OK
Downloading 16128 bytes @ address 0x08091AF0 - Verified OK
Downloading 16288 bytes @ address 0x080959F0 - Verified OK
Downloading 16272 bytes @ address 0x08099990 - Verified OK
Downloading 16256 bytes @ address 0x0809D920 - Verified OK
Downloading 14880 bytes @ address 0x080A18A0 - Verified OK
Downloading 8 bytes @ address 0x080A52C0 - Verified OK
Downloading 4 bytes @ address 0x080A52C8 - Verified OK
Downloading 4 bytes @ address 0x080A52CC - Verified OK
Downloading 1068 bytes @ address 0x080A52D0 - Verified OK
Comparing flash   [....................] Done.
Erasing flash     [....................] Done.
Programming flash [....................] Done.
Verifying flash   [....................] Done.
Writing register (PC = 0x08083ED0)
Read 4 bytes @ address 0x08083ED0 (Data = 0xE0032100)
Read 2 bytes @ address 0x08083ED0 (Data = 0x2100)
Read 2 bytes @ address 0x0807BAAE (Data = 0xF44F)
Read 2 bytes @ address 0x0807BAAE (Data = 0xF44F)
Read 2 bytes @ address 0x0807BAFA (Data = 0xF44F)
Read 2 bytes @ address 0x0807BAFA (Data = 0xF44F)
Read 2 bytes @ address 0x08080814 (Data = 0x4B14)
Read 4 bytes @ address 0x08080868 (Data = 0x2002B994)
Read 2 bytes @ address 0x08080814 (Data = 0x4B14)
Read 2 bytes @ address 0x0807BB44 (Data = 0x687B)
Read 2 bytes @ address 0x0807BBB2 (Data = 0xF897)
Resetting target
Halting target CPU...
...Target halted (PC = 0x080023CC)
Read 2 bytes @ address 0x08080814 (Data = 0x4B14)
Read 4 bytes @ address 0x08080868 (Data = 0x2002B994)
Read 2 bytes @ address 0x08080814 (Data = 0x4B14)
Read 4 bytes @ address 0x08080868 (Data = 0x2002B994)
Read 2 bytes @ address 0x08080814 (Data = 0x4B14)
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000, R13= 20080000, MSP= 20080000, PSP= 00000000
R14(LR) = FFFFFFFF, R15(PC) = 080023CC
XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
Reading all registers
Read 4 bytes @ address 0x080023CC (Data = 0xD034F8DF)
Read 2 bytes @ address 0x080023CC (Data = 0xF8DF)
Setting breakpoint @ address 0x0807BAAE, Size = 2, BPHandle = 0x0001
Setting breakpoint @ address 0x0807BAFA, Size = 2, BPHandle = 0x0002
Setting breakpoint @ address 0x0807BBB2, Size = 2, BPHandle = 0x0003
Setting breakpoint @ address 0x08080814, Size = 2, BPHandle = 0x0004
Starting target CPU...
...Target halted (DBGRQ, PC = 0xFFFFFFFE)
Reading all registers
WARNING: Failed to read memory @ address 0xFFFFFFFE
Removing breakpoint @ address 0x0807BAAE, Size = 2
Removing breakpoint @ address 0x0807BAFA, Size = 2
Removing breakpoint @ address 0x0807BBB2, Size = 2
Removing breakpoint @ address 0x08080814, Size = 2
WARNING: Failed to read memory @ address 0xFFFFFFF4
Reading 64 bytes @ address 0xFFFFFFC0
WARNING: Failed to read memory @ address 0xFFFFFFC0
WARNING: Failed to read memory @ address 0xFFFFFFF0
Reading 64 bytes @ address 0xFFFFFFC0
WARNING: Failed to read memory @ address 0xFFFFFFC0
WARNING: Failed to read memory @ address 0xFFFFFFF0
</code>```

Successful JLINK debug if it doesn't flash:

```<code>SEGGER J-Link GDB Server V6.16c Command Line Version
JLinkARM.dll V6.16c (DLL compiled Jun 16 2017 18:14:49)

WARNING: Unknown command line parameter -timeout found.
WARNING: Unknown command line parameter 0 found.
-----GDB Server start settings-----
GDBInit file:                  none
GDB Server Listening port:     2331
SWO raw output listening port: 2332
Terminal I/O port:             2333
Accept remote connection:      localhost only
Generate logfile:              off
Verify download:               on
Init regs on start:            on
Silent mode:                   off
Single run mode:               on
Target connection timeout:     0 ms
------J-Link related settings------
J-Link Host interface:         USB
J-Link script:                 none
J-Link settings file:          none
------Target related settings------
Target device:                 STM32F765VI
Target interface:              SWD
Target interface speed:        1000kHz
Target endian:                 little

Connecting to J-Link...
J-Link is connected.
Firmware: J-Link V10 compiled Jun 16 2017 16:15:19
Hardware: V10.10
S/N: 260101191
OEM: SEGGER-EDU
Feature(s): FlashBP, GDB
Checking target voltage...
Target voltage: 3.35 V
Listening on TCP/IP port 2331
Connecting to target...Connected to target
Waiting for GDB connection...Connected to 127.0.0.1
Reading all registers
Read 4 bytes @ address 0x00000000 (Data = 0x51E9FF66)
Read 2 bytes @ address 0x00000000 (Data = 0xFF66)
Target interface speed set to 1000 kHz
Resetting target
Halting target CPU...
...Target halted (PC = 0x080023CC)
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000, R13= 20080000, MSP= 20080000, PSP= 00000000
R14(LR) = FFFFFFFF, R15(PC) = 080023CC
XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
Reading all registers
Read 4 bytes @ address 0x080023CC (Data = 0xD034F8DF)
Read 2 bytes @ address 0x080023CC (Data = 0xF8DF)
Target interface speed set to 15000 kHz
Flash breakpoints enabled
SWO disabled succesfully.
SWO enabled succesfully.
Read 4 bytes @ address 0x080023CC (Data = 0xD034F8DF)
Read 2 bytes @ address 0x080023CC (Data = 0xF8DF)
Downloading 520 bytes @ address 0x08020000 - Verified OK
Downloading 16064 bytes @ address 0x08020210 - Verified OK
Downloading 16096 bytes @ address 0x080240D0 - Verified OK
Downloading 16048 bytes @ address 0x08027FB0 - Verified OK
Downloading 16112 bytes @ address 0x0802BE60 - Verified OK
Downloading 16096 bytes @ address 0x0802FD50 - Verified OK
Downloading 16112 bytes @ address 0x08033C30 - Verified OK
Downloading 16144 bytes @ address 0x08037B20 - Verified OK
Downloading 16000 bytes @ address 0x0803BA30 - Verified OK
Downloading 15920 bytes @ address 0x0803F8B0 - Verified OK
Downloading 16176 bytes @ address 0x080436E0 - Verified OK
Downloading 16064 bytes @ address 0x08047610 - Verified OK
Downloading 16032 bytes @ address 0x0804B4D0 - Verified OK
Downloading 15696 bytes @ address 0x0804F370 - Verified OK
Downloading 16032 bytes @ address 0x080530C0 - Verified OK
Downloading 16176 bytes @ address 0x08056F60 - Verified OK
Downloading 16064 bytes @ address 0x0805AE90 - Verified OK
Downloading 16064 bytes @ address 0x0805ED50 - Verified OK
Downloading 16128 bytes @ address 0x08062C10 - Verified OK
Downloading 16176 bytes @ address 0x08066B10 - Verified OK
Downloading 16112 bytes @ address 0x0806AA40 - Verified OK
Downloading 16304 bytes @ address 0x0806E930 - Verified OK
Downloading 16272 bytes @ address 0x080728E0 - Verified OK
Downloading 16048 bytes @ address 0x08076870 - Verified OK
Downloading 16080 bytes @ address 0x0807A720 - Verified OK
Downloading 16048 bytes @ address 0x0807E5F0 - Verified OK
Downloading 16048 bytes @ address 0x080824A0 - Verified OK
Downloading 14616 bytes @ address 0x08086350 - Verified OK
Downloading 16144 bytes @ address 0x08089C80 - Verified OK
Downloading 16224 bytes @ address 0x0808DB90 - Verified OK
Downloading 16128 bytes @ address 0x08091AF0 - Verified OK
Downloading 16288 bytes @ address 0x080959F0 - Verified OK
Downloading 16272 bytes @ address 0x08099990 - Verified OK
Downloading 16256 bytes @ address 0x0809D920 - Verified OK
Downloading 14880 bytes @ address 0x080A18A0 - Verified OK
Downloading 8 bytes @ address 0x080A52C0 - Verified OK
Downloading 4 bytes @ address 0x080A52C8 - Verified OK
Downloading 4 bytes @ address 0x080A52CC - Verified OK
Downloading 1068 bytes @ address 0x080A52D0 - Verified OK
Comparing flash   [....................] Done.
Verifying flash   [....................] Done.
Writing register (PC = 0x08083ED0)
Read 4 bytes @ address 0x08083ED0 (Data = 0xD034F8DF)
Read 2 bytes @ address 0x08083ED0 (Data = 0xF8DF)
Read 2 bytes @ address 0x08083ED2 (Data = 0xD034)
Read 2 bytes @ address 0x0807BAAE (Data = 0xF44F)
Read 2 bytes @ address 0x0807BAAE (Data = 0xF44F)
Read 2 bytes @ address 0x0807BB44 (Data = 0x687B)
Read 2 bytes @ address 0x0807BBB2 (Data = 0xF897)
Read 2 bytes @ address 0x0807BAFA (Data = 0xF44F)
Read 2 bytes @ address 0x0807BAFA (Data = 0xF44F)
Resetting target
Halting target CPU...
...Target halted (PC = 0x080023CC)
Read 2 bytes @ address 0x08080814 (Data = 0x4B15)
Read 4 bytes @ address 0x0808086C (Data = 0x2002B994)
Read 2 bytes @ address 0x08080814 (Data = 0x4B15)
Read 4 bytes @ address 0x0808086C (Data = 0x2002B994)
Read 2 bytes @ address 0x08080814 (Data = 0x4B15)
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000, R13= 20080000, MSP= 20080000, PSP= 00000000
R14(LR) = FFFFFFFF, R15(PC) = 080023CC
XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
Reading all registers
Read 4 bytes @ address 0x080023CC (Data = 0xD034F8DF)
Read 2 bytes @ address 0x080023CC (Data = 0xF8DF)
Setting breakpoint @ address 0x0807BAAE, Size = 2, BPHandle = 0x0001
Setting breakpoint @ address 0x0807BAFA, Size = 2, BPHandle = 0x0002
Setting breakpoint @ address 0x0807BBB2, Size = 2, BPHandle = 0x0003
Setting breakpoint @ address 0x08080814, Size = 2, BPHandle = 0x0004
Starting target CPU...
...Breakpoint reached @ address 0x08080814
Reading all registers
Read 4 bytes @ address 0x08080814 (Data = 0x68184B15)
Removing breakpoint @ address 0x0807BAAE, Size = 2
Removing breakpoint @ address 0x0807BAFA, Size = 2
Removing breakpoint @ address 0x0807BBB2, Size = 2
Removing breakpoint @ address 0x08080814, Size = 2
Reading 64 bytes @ address 0x20003A40
Read 4 bytes @ address 0x0802ED40 (Data = 0xB083B480)
Reading 64 bytes @ address 0x200039C0
Read 4 bytes @ address 0x0802ED40 (Data = 0xB083B480)
</code>```

STLINK success debug

```<code>Open On-Chip Debugger 0.10.0-dev-00278-ga53935e-dirty (2017-05-09-09:25)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
srst_only separate srst_nogate srst_open_drain connect_assert_srst
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 4000 kHz
adapter_nsrst_delay: 100
Info : clock speed 4000 kHz
Info : STLINK v2 JTAG v27 API v2 M v15 VID 0x0483 PID 0x374B
Info : using stlink api v2
Info : Target voltage: 0.023669
Error: target voltage may be too low for reliable debugging
Info : STM32F765VITx.cpu: hardware has 8 breakpoints, 4 watchpoints
Info : accepting 'gdb' connection on tcp/3333
STM32F765VITx.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080023cc msp: 0x20080000
Info : flash size probed value 2048
Info : flash size probed value 2048
STM32F765VITx.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080023cc msp: 0x20080000
STM32F765VITx.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080023cc msp: 0x20080000
Info : Padding image section 0 with 8 bytes
Info : Padding image section 1 with 24 bytes
STM32F765VITx.cpu: target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x20000084 msp: 0x20080000
Warn : keep_alive() was not invoked in the 1000ms timelimit. GDB alive packet not sent! (4290). Workaround: increase "set remotetimeout" in GDB
STM32F765VITx.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080023cc msp: 0x20080000
</code>```

JLINK commander failed log

```<code>SEGGER J-Link Commander V6.16c (Compiled Jun 16 2017 18:15:26)
DLL version V6.16c, compiled Jun 16 2017 18:14:49

Connecting to J-Link via USB...O.K.
Firmware: J-Link V10 compiled Jun 16 2017 16:15:19
Hardware version: V10.10
S/N: 260101191
License(s): FlashBP, GDB
OEM: SEGGER-EDU
VTref = 3.348V

Type "connect" to establish a target connection, '?' for help
J-Link>connect
Please specify device / core. <Default>: STM32F765VI
Type '?' for selection dialog
Device>
Please specify target interface:
  J) JTAG (Default)
  S) SWD
TIF>s
Specify target interface speed [kHz]. <Default>: 4000 kHz
Speed>
Device "STM32F765VI" selected.

Connecting to target via SWD
Found SW-DP with ID 0x5BA02477
Found SW-DP with ID 0x5BA02477
Scanning APs, stopping at first AHB-AP found.
AP[0] IDR: 0x74770001 (AHB-AP)
AHB-AP ROM: 0xE00FD000 (Base addr. of first ROM table)
CPUID reg: 0x411FC270. Implementer code: 0x41 (ARM)
Found Cortex-M7 r1p0, Little endian.
FPUnit: 8 code (BP) slots and 0 literal slots
CoreSight components:
ROMTbl[0] @ E00FD000
ROMTbl[0][0]: E00FE000, CID: B105100D, PID: 000BB4C8 ROM Table
ROMTbl[1] @ E00FE000
ROMTbl[1][0]: E00FF000, CID: B105100D, PID: 000BB4C7 ROM Table
ROMTbl[2] @ E00FF000
ROMTbl[2][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS
ROMTbl[2][1]: E0001000, CID: B105E00D, PID: 000BB002 DWT
ROMTbl[2][2]: E0002000, CID: B105E00D, PID: 000BB00E FPB
ROMTbl[2][3]: E0000000, CID: B105E00D, PID: 000BB001 ITM
ROMTbl[1][1]: E0041000, CID: B105900D, PID: 001BB975 ETM-M7
ROMTbl[0][1]: E0040000, CID: B105900D, PID: 000BB9A9 TPIU-M7
Cache: Separate I- and D-cache.
I-Cache L1: 16 KB, 256 Sets, 32 Bytes/Line, 2-Way
D-Cache L1: 16 KB, 128 Sets, 32 Bytes/Line, 4-Way
Cortex-M7 identified.
J-Link>r
Reset delay: 0 ms
Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
Setting AIRCR.SYSRESETREQ
J-Link>loadbin C:\Users\User\workspace_10\DC_Booster_F756\Debug\DC_Booster_F756.bin,0x08020000
Downloading file [C:\Users\User\workspace_10\DC_Booster_F756\Debug\DC_Booster_F756.bin]...
J-Link: Flash download: Flash programming performed for 2 ranges (131072 bytes)
J-Link: Flash download: Total time needed: 6.157s (Prepare: 0.022s, Compare: 0.081s, Erase: 4.931s, Program: 1.116s, Verify: 0.000s, Restore: 0.005s)
J-Link: Flash download: Restarting flash programming due to program error (possibly skipped erasure of half-way erased sector).
J-Link: Flash download: Skip optimizations disabled for second try.
Error while programming flash: Programming failed.
J-Link>verifybin C:\Users\User\workspace_10\DC_Booster_F756\Debug\DC_Booster_F756.bin,0x08020000
Loading binary file C:\Users\User\workspace_10\DC_Booster_F756\Debug\DC_Booster_F756.bin
Reading 546556 bytes data from target memory @ 0x08020000.
Verify failed @ address 0x08065522.
Expected FE read 00J-Link>
</code>```

答:
I reached over to the guys at Segger and they created a wiki page detailing how to resolve the issue. To make the Jlink aware of the Dual Bank config on STM32F7 devices, Jlink Open Flash loader must be used with custom script containing info of the Dual Bank config. Once that's done, the Jlink debugger has no problem when the program jumps from bootloader to main app. Here are the steps for getting Jlink to work with STM32F765VI operating in Dual Bank mode.

First off, use the latest version  from 616f onwards

download and place the precompiled binary (ST STM32F7xxxx_2MB_DualBank.elf)from Jlink wiki to folder containing Jlink.exe and JLinkDevices.xml

edit JLinkDevices.xml to contain info related to the MCU and direct it to use the precompiled binary instead of the default one in Jlink. Add the following beneath the database tag at the start:

<Device>

<ChipInfo Vendor="ST" Name="STM32F765VI" Core="JLINK_CORE_CORTEX_M7" />
<FlashBankInfo Name="Internes Flash" BaseAddr="0x08000000" MaxSize="0x00200000 " Loader="ST_STM32F7xxxx_2MB_DualBank.elf" LoaderType="FLASH_ALGO_TYPE_OPEN" />
</Device>

If you have multiple versions of Jlink installed, make sure you're using the one which has its JLinkDevices.xml edited to use the precompiled binary in your debugging session.

Body:
I'm using the J-Link EDU and STLink debugger present on the Nucleo boards from ST. For testing, the bootloader code is present at 0x8000000 and just jumps to 0x8020000 where the main app code is present. When I use the Jlink EDU, it can't program the flash at 0x8020000 every time successfully and if I modify the program and start debugging, the Jlink erases the flash but does not program it successfully and after the bootloader makes the jump, the MCU gets HardFault. Now this happens whether I use Jlink or the STLINK (converted to Jlink). Usually I see it stuck at 0xFFFFFFFE. At that point the JLINK has erased the app code but failed to program it.

The interesting thing is that the STlink debugger when converted back and used with openocd has no issues whatsoever with the bootloader jumping to main app code and debugging from there.

I also find that if I program the main app code at 0x8020000 by STLink and OpenOCD and then switch to JLINK EDU for debug, it works as long as the JLINK does't reprogram it. If in the log, I see that the JLINK flashes the code, then the ST crashes after jumping from bootloader. So I definitely think it has something to do with how the JLINK is erasing and programming the ST during debug.

I also tried programming with JLINK commander and that seems to fail as well. Unless I fully erase the chip.

I'm using System Workbench 2.0 with GNU ARM Eclipse plugin for Jlink debugging with the latest ARM toolchain as of this date and Jlink 616c. I'm using the STM32F765VI with the flash in dual bank configuration.

I'm also attaching the GDB logs from JLINK and STLINK for clarity. I would like to use JLINK for debugging since I can have SWO console in eclipse whereas its very cumbersome in OpenOCD so would like to resolve it.

Failed JLINK debug after it tried to program:

SEGGER J-Link GDB Server V6.16c Command Line Version
JLinkARM.dll V6.16c (DLL compiled Jun 16 2017 18:14:49)

WARNING: Unknown command line parameter -timeout found.
WARNING: Unknown command line parameter 0 found.
-----GDB Server start settings-----
GDBInit file:                  none
GDB Server Listening port:     2331
SWO raw output listening port: 2332
Terminal I/O port:             2333
Accept remote connection:      localhost only
Generate logfile:              off
Verify download:               on
Init regs on start:            on
Silent mode:                   off
Single run mode:               on
Target connection timeout:     0 ms
------J-Link related settings------
J-Link Host interface:         USB
J-Link script:                 none
J-Link settings file:          none
------Target related settings------
Target device:                 STM32F765VI
Target interface:              SWD
Target interface speed:        1000kHz
Target endian:                 little

Connecting to J-Link...
J-Link is connected.
Firmware: J-Link V10 compiled Jun 16 2017 16:15:19
Hardware: V10.10
S/N: 260101191
OEM: SEGGER-EDU
Feature(s): FlashBP, GDB
Checking target voltage...
Target voltage: 3.35 V
Listening on TCP/IP port 2331
Connecting to target...Connected to target
Waiting for GDB connection...Connected to 127.0.0.1
Reading all registers
Read 4 bytes @ address 0x00000000 (Data = 0x51E9FF66)
Read 2 bytes @ address 0x00000000 (Data = 0xFF66)
Target interface speed set to 1000 kHz
Resetting target
Halting target CPU...
...Target halted (PC = 0x080023CC)
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000, R13= 20080000, MSP= 20080000, PSP= 00000000
R14(LR) = FFFFFFFF, R15(PC) = 080023CC
XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
Reading all registers
Read 4 bytes @ address 0x080023CC (Data = 0xD034F8DF)
Read 2 bytes @ address 0x080023CC (Data = 0xF8DF)
Target interface speed set to 15000 kHz
Flash breakpoints enabled
SWO disabled succesfully.
SWO enabled succesfully.
Read 4 bytes @ address 0x080023CC (Data = 0xD034F8DF)
Read 2 bytes @ address 0x080023CC (Data = 0xF8DF)
Downloading 520 bytes @ address 0x08020000 - Verified OK
Downloading 16064 bytes @ address 0x08020210 - Verified OK
Downloading 16096 bytes @ address 0x080240D0 - Verified OK
Downloading 16048 bytes @ address 0x08027FB0 - Verified OK
Downloading 16112 bytes @ address 0x0802BE60 - Verified OK
Downloading 16096 bytes @ address 0x0802FD50 - Verified OK
Downloading 16112 bytes @ address 0x08033C30 - Verified OK
Downloading 16144 bytes @ address 0x08037B20 - Verified OK
Downloading 16000 bytes @ address 0x0803BA30 - Verified OK
Downloading 15920 bytes @ address 0x0803F8B0 - Verified OK
Downloading 16176 bytes @ address 0x080436E0 - Verified OK
Downloading 16064 bytes @ address 0x08047610 - Verified OK
Downloading 16032 bytes @ address 0x0804B4D0 - Verified OK
Downloading 15696 bytes @ address 0x0804F370 - Verified OK
Downloading 16032 bytes @ address 0x080530C0 - Verified OK
Downloading 16176 bytes @ address 0x08056F60 - Verified OK
Downloading 16064 bytes @ address 0x0805AE90 - Verified OK
Downloading 16064 bytes @ address 0x0805ED50 - Verified OK
Downloading 16128 bytes @ address 0x08062C10 - Verified OK
Downloading 16176 bytes @ address 0x08066B10 - Verified OK
Downloading 16112 bytes @ address 0x0806AA40 - Verified OK
Downloading 16304 bytes @ address 0x0806E930 - Verified OK
Downloading 16272 bytes @ address 0x080728E0 - Verified OK
Downloading 16048 bytes @ address 0x08076870 - Verified OK
Downloading 16080 bytes @ address 0x0807A720 - Verified OK
Downloading 16048 bytes @ address 0x0807E5F0 - Verified OK
Downloading 16048 bytes @ address 0x080824A0 - Verified OK
Downloading 14616 bytes @ address 0x08086350 - Verified OK
Downloading 16144 bytes @ address 0x08089C80 - Verified OK
Downloading 16224 bytes @ address 0x0808DB90 - Verified OK
Downloading 16128 bytes @ address 0x08091AF0 - Verified OK
Downloading 16288 bytes @ address 0x080959F0 - Verified OK
Downloading 16272 bytes @ address 0x08099990 - Verified OK
Downloading 16256 bytes @ address 0x0809D920 - Verified OK
Downloading 14880 bytes @ address 0x080A18A0 - Verified OK
Downloading 8 bytes @ address 0x080A52C0 - Verified OK
Downloading 4 bytes @ address 0x080A52C8 - Verified OK
Downloading 4 bytes @ address 0x080A52CC - Verified OK
Downloading 1068 bytes @ address 0x080A52D0 - Verified OK
Comparing flash   [....................] Done.
Erasing flash     [....................] Done.
Programming flash [....................] Done.
Verifying flash   [....................] Done.
Writing register (PC = 0x08083ED0)
Read 4 bytes @ address 0x08083ED0 (Data = 0xE0032100)
Read 2 bytes @ address 0x08083ED0 (Data = 0x2100)
Read 2 bytes @ address 0x0807BAAE (Data = 0xF44F)
Read 2 bytes @ address 0x0807BAAE (Data = 0xF44F)
Read 2 bytes @ address 0x0807BAFA (Data = 0xF44F)
Read 2 bytes @ address 0x0807BAFA (Data = 0xF44F)
Read 2 bytes @ address 0x08080814 (Data = 0x4B14)
Read 4 bytes @ address 0x08080868 (Data = 0x2002B994)
Read 2 bytes @ address 0x08080814 (Data = 0x4B14)
Read 2 bytes @ address 0x0807BB44 (Data = 0x687B)
Read 2 bytes @ address 0x0807BBB2 (Data = 0xF897)
Resetting target
Halting target CPU...
...Target halted (PC = 0x080023CC)
Read 2 bytes @ address 0x08080814 (Data = 0x4B14)
Read 4 bytes @ address 0x08080868 (Data = 0x2002B994)
Read 2 bytes @ address 0x08080814 (Data = 0x4B14)
Read 4 bytes @ address 0x08080868 (Data = 0x2002B994)
Read 2 bytes @ address 0x08080814 (Data = 0x4B14)
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000, R13= 20080000, MSP= 20080000, PSP= 00000000
R14(LR) = FFFFFFFF, R15(PC) = 080023CC
XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
Reading all registers
Read 4 bytes @ address 0x080023CC (Data = 0xD034F8DF)
Read 2 bytes @ address 0x080023CC (Data = 0xF8DF)
Setting breakpoint @ address 0x0807BAAE, Size = 2, BPHandle = 0x0001
Setting breakpoint @ address 0x0807BAFA, Size = 2, BPHandle = 0x0002
Setting breakpoint @ address 0x0807BBB2, Size = 2, BPHandle = 0x0003
Setting breakpoint @ address 0x08080814, Size = 2, BPHandle = 0x0004
Starting target CPU...
...Target halted (DBGRQ, PC = 0xFFFFFFFE)
Reading all registers
WARNING: Failed to read memory @ address 0xFFFFFFFE
Removing breakpoint @ address 0x0807BAAE, Size = 2
Removing breakpoint @ address 0x0807BAFA, Size = 2
Removing breakpoint @ address 0x0807BBB2, Size = 2
Removing breakpoint @ address 0x08080814, Size = 2
WARNING: Failed to read memory @ address 0xFFFFFFF4
Reading 64 bytes @ address 0xFFFFFFC0
WARNING: Failed to read memory @ address 0xFFFFFFC0
WARNING: Failed to read memory @ address 0xFFFFFFF0
Reading 64 bytes @ address 0xFFFFFFC0
WARNING: Failed to read memory @ address 0xFFFFFFC0
WARNING: Failed to read memory @ address 0xFFFFFFF0

Successful JLINK debug if it doesn't flash:

SEGGER J-Link GDB Server V6.16c Command Line Version
JLinkARM.dll V6.16c (DLL compiled Jun 16 2017 18:14:49)

WARNING: Unknown command line parameter -timeout found.
WARNING: Unknown command line parameter 0 found.
-----GDB Server start settings-----
GDBInit file:                  none
GDB Server Listening port:     2331
SWO raw output listening port: 2332
Terminal I/O port:             2333
Accept remote connection:      localhost only
Generate logfile:              off
Verify download:               on
Init regs on start:            on
Silent mode:                   off
Single run mode:               on
Target connection timeout:     0 ms
------J-Link related settings------
J-Link Host interface:         USB
J-Link script:                 none
J-Link settings file:          none
------Target related settings------
Target device:                 STM32F765VI
Target interface:              SWD
Target interface speed:        1000kHz
Target endian:                 little

Connecting to J-Link...
J-Link is connected.
Firmware: J-Link V10 compiled Jun 16 2017 16:15:19
Hardware: V10.10
S/N: 260101191
OEM: SEGGER-EDU
Feature(s): FlashBP, GDB
Checking target voltage...
Target voltage: 3.35 V
Listening on TCP/IP port 2331
Connecting to target...Connected to target
Waiting for GDB connection...Connected to 127.0.0.1
Reading all registers
Read 4 bytes @ address 0x00000000 (Data = 0x51E9FF66)
Read 2 bytes @ address 0x00000000 (Data = 0xFF66)
Target interface speed set to 1000 kHz
Resetting target
Halting target CPU...
...Target halted (PC = 0x080023CC)
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000, R13= 20080000, MSP= 20080000, PSP= 00000000
R14(LR) = FFFFFFFF, R15(PC) = 080023CC
XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
Reading all registers
Read 4 bytes @ address 0x080023CC (Data = 0xD034F8DF)
Read 2 bytes @ address 0x080023CC (Data = 0xF8DF)
Target interface speed set to 15000 kHz
Flash breakpoints enabled
SWO disabled succesfully.
SWO enabled succesfully.
Read 4 bytes @ address 0x080023CC (Data = 0xD034F8DF)
Read 2 bytes @ address 0x080023CC (Data = 0xF8DF)
Downloading 520 bytes @ address 0x08020000 - Verified OK
Downloading 16064 bytes @ address 0x08020210 - Verified OK
Downloading 16096 bytes @ address 0x080240D0 - Verified OK
Downloading 16048 bytes @ address 0x08027FB0 - Verified OK
Downloading 16112 bytes @ address 0x0802BE60 - Verified OK
Downloading 16096 bytes @ address 0x0802FD50 - Verified OK
Downloading 16112 bytes @ address 0x08033C30 - Verified OK
Downloading 16144 bytes @ address 0x08037B20 - Verified OK
Downloading 16000 bytes @ address 0x0803BA30 - Verified OK
Downloading 15920 bytes @ address 0x0803F8B0 - Verified OK
Downloading 16176 bytes @ address 0x080436E0 - Verified OK
Downloading 16064 bytes @ address 0x08047610 - Verified OK
Downloading 16032 bytes @ address 0x0804B4D0 - Verified OK
Downloading 15696 bytes @ address 0x0804F370 - Verified OK
Downloading 16032 bytes @ address 0x080530C0 - Verified OK
Downloading 16176 bytes @ address 0x08056F60 - Verified OK
Downloading 16064 bytes @ address 0x0805AE90 - Verified OK
Downloading 16064 bytes @ address 0x0805ED50 - Verified OK
Downloading 16128 bytes @ address 0x08062C10 - Verified OK
Downloading 16176 bytes @ address 0x08066B10 - Verified OK
Downloading 16112 bytes @ address 0x0806AA40 - Verified OK
Downloading 16304 bytes @ address 0x0806E930 - Verified OK
Downloading 16272 bytes @ address 0x080728E0 - Verified OK
Downloading 16048 bytes @ address 0x08076870 - Verified OK
Downloading 16080 bytes @ address 0x0807A720 - Verified OK
Downloading 16048 bytes @ address 0x0807E5F0 - Verified OK
Downloading 16048 bytes @ address 0x080824A0 - Verified OK
Downloading 14616 bytes @ address 0x08086350 - Verified OK
Downloading 16144 bytes @ address 0x08089C80 - Verified OK
Downloading 16224 bytes @ address 0x0808DB90 - Verified OK
Downloading 16128 bytes @ address 0x08091AF0 - Verified OK
Downloading 16288 bytes @ address 0x080959F0 - Verified OK
Downloading 16272 bytes @ address 0x08099990 - Verified OK
Downloading 16256 bytes @ address 0x0809D920 - Verified OK
Downloading 14880 bytes @ address 0x080A18A0 - Verified OK
Downloading 8 bytes @ address 0x080A52C0 - Verified OK
Downloading 4 bytes @ address 0x080A52C8 - Verified OK
Downloading 4 bytes @ address 0x080A52CC - Verified OK
Downloading 1068 bytes @ address 0x080A52D0 - Verified OK
Comparing flash   [....................] Done.
Verifying flash   [....................] Done.
Writing register (PC = 0x08083ED0)
Read 4 bytes @ address 0x08083ED0 (Data = 0xD034F8DF)
Read 2 bytes @ address 0x08083ED0 (Data = 0xF8DF)
Read 2 bytes @ address 0x08083ED2 (Data = 0xD034)
Read 2 bytes @ address 0x0807BAAE (Data = 0xF44F)
Read 2 bytes @ address 0x0807BAAE (Data = 0xF44F)
Read 2 bytes @ address 0x0807BB44 (Data = 0x687B)
Read 2 bytes @ address 0x0807BBB2 (Data = 0xF897)
Read 2 bytes @ address 0x0807BAFA (Data = 0xF44F)
Read 2 bytes @ address 0x0807BAFA (Data = 0xF44F)
Resetting target
Halting target CPU...
...Target halted (PC = 0x080023CC)
Read 2 bytes @ address 0x08080814 (Data = 0x4B15)
Read 4 bytes @ address 0x0808086C (Data = 0x2002B994)
Read 2 bytes @ address 0x08080814 (Data = 0x4B15)
Read 4 bytes @ address 0x0808086C (Data = 0x2002B994)
Read 2 bytes @ address 0x08080814 (Data = 0x4B15)
R0 = 00000000, R1 = 00000000, R2 = 00000000, R3 = 00000000
R4 = 00000000, R5 = 00000000, R6 = 00000000, R7 = 00000000
R8 = 00000000, R9 = 00000000, R10= 00000000, R11= 00000000
R12= 00000000, R13= 20080000, MSP= 20080000, PSP= 00000000
R14(LR) = FFFFFFFF, R15(PC) = 080023CC
XPSR 01000000, APSR 00000000, EPSR 01000000, IPSR 00000000
CFBP 00000000, CONTROL 00, FAULTMASK 00, BASEPRI 00, PRIMASK 00
Reading all registers
Read 4 bytes @ address 0x080023CC (Data = 0xD034F8DF)
Read 2 bytes @ address 0x080023CC (Data = 0xF8DF)
Setting breakpoint @ address 0x0807BAAE, Size = 2, BPHandle = 0x0001
Setting breakpoint @ address 0x0807BAFA, Size = 2, BPHandle = 0x0002
Setting breakpoint @ address 0x0807BBB2, Size = 2, BPHandle = 0x0003
Setting breakpoint @ address 0x08080814, Size = 2, BPHandle = 0x0004
Starting target CPU...
...Breakpoint reached @ address 0x08080814
Reading all registers
Read 4 bytes @ address 0x08080814 (Data = 0x68184B15)
Removing breakpoint @ address 0x0807BAAE, Size = 2
Removing breakpoint @ address 0x0807BAFA, Size = 2
Removing breakpoint @ address 0x0807BBB2, Size = 2
Removing breakpoint @ address 0x08080814, Size = 2
Reading 64 bytes @ address 0x20003A40
Read 4 bytes @ address 0x0802ED40 (Data = 0xB083B480)
Reading 64 bytes @ address 0x200039C0
Read 4 bytes @ address 0x0802ED40 (Data = 0xB083B480)

STLINK success debug

Open On-Chip Debugger 0.10.0-dev-00278-ga53935e-dirty (2017-05-09-09:25)
Licensed under GNU GPL v2
For bug reports, read
    http://openocd.org/doc/doxygen/bugs.html
srst_only separate srst_nogate srst_open_drain connect_assert_srst
Info : The selected transport took over low-level target control. The results might differ compared to plain JTAG/SWD
adapter speed: 4000 kHz
adapter_nsrst_delay: 100
Info : clock speed 4000 kHz
Info : STLINK v2 JTAG v27 API v2 M v15 VID 0x0483 PID 0x374B
Info : using stlink api v2
Info : Target voltage: 0.023669
Error: target voltage may be too low for reliable debugging
Info : STM32F765VITx.cpu: hardware has 8 breakpoints, 4 watchpoints
Info : accepting 'gdb' connection on tcp/3333
STM32F765VITx.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080023cc msp: 0x20080000
Info : flash size probed value 2048
Info : flash size probed value 2048
STM32F765VITx.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080023cc msp: 0x20080000
STM32F765VITx.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080023cc msp: 0x20080000
Info : Padding image section 0 with 8 bytes
Info : Padding image section 1 with 24 bytes
STM32F765VITx.cpu: target state: halted
target halted due to breakpoint, current mode: Thread
xPSR: 0x61000000 pc: 0x20000084 msp: 0x20080000
Warn : keep_alive() was not invoked in the 1000ms timelimit. GDB alive packet not sent! (4290). Workaround: increase "set remotetimeout" in GDB
STM32F765VITx.cpu: target state: halted
target halted due to debug-request, current mode: Thread
xPSR: 0x01000000 pc: 0x080023cc msp: 0x20080000

JLINK commander failed log

SEGGER J-Link Commander V6.16c (Compiled Jun 16 2017 18:15:26)
DLL version V6.16c, compiled Jun 16 2017 18:14:49

Connecting to J-Link via USB...O.K.
Firmware: J-Link V10 compiled Jun 16 2017 16:15:19
Hardware version: V10.10
S/N: 260101191
License(s): FlashBP, GDB
OEM: SEGGER-EDU
VTref = 3.348V

Type "connect" to establish a target connection, '?' for help
J-Link>connect
Please specify device / core. <Default>: STM32F765VI
Type '?' for selection dialog
Device>
Please specify target interface:
  J) JTAG (Default)
  S) SWD
TIF>s
Specify target interface speed [kHz]. <Default>: 4000 kHz
Speed>
Device "STM32F765VI" selected.

Connecting to target via SWD
Found SW-DP with ID 0x5BA02477
Found SW-DP with ID 0x5BA02477
Scanning APs, stopping at first AHB-AP found.
AP[0] IDR: 0x74770001 (AHB-AP)
AHB-AP ROM: 0xE00FD000 (Base addr. of first ROM table)
CPUID reg: 0x411FC270. Implementer code: 0x41 (ARM)
Found Cortex-M7 r1p0, Little endian.
FPUnit: 8 code (BP) slots and 0 literal slots
CoreSight components:
ROMTbl[0] @ E00FD000
ROMTbl[0][0]: E00FE000, CID: B105100D, PID: 000BB4C8 ROM Table
ROMTbl[1] @ E00FE000
ROMTbl[1][0]: E00FF000, CID: B105100D, PID: 000BB4C7 ROM Table
ROMTbl[2] @ E00FF000
ROMTbl[2][0]: E000E000, CID: B105E00D, PID: 000BB00C SCS
ROMTbl[2][1]: E0001000, CID: B105E00D, PID: 000BB002 DWT
ROMTbl[2][2]: E0002000, CID: B105E00D, PID: 000BB00E FPB
ROMTbl[2][3]: E0000000, CID: B105E00D, PID: 000BB001 ITM
ROMTbl[1][1]: E0041000, CID: B105900D, PID: 001BB975 ETM-M7
ROMTbl[0][1]: E0040000, CID: B105900D, PID: 000BB9A9 TPIU-M7
Cache: Separate I- and D-cache.
I-Cache L1: 16 KB, 256 Sets, 32 Bytes/Line, 2-Way
D-Cache L1: 16 KB, 128 Sets, 32 Bytes/Line, 4-Way
Cortex-M7 identified.
J-Link>r
Reset delay: 0 ms
Reset type NORMAL: Resets core & peripherals via SYSRESETREQ & VECTRESET bit.
Setting AIRCR.SYSRESETREQ
J-Link>loadbin C:\Users\User\workspace_10\DC_Booster_F756\Debug\DC_Booster_F756.bin,0x08020000
Downloading file [C:\Users\User\workspace_10\DC_Booster_F756\Debug\DC_Booster_F756.bin]...
J-Link: Flash download: Flash programming performed for 2 ranges (131072 bytes)
J-Link: Flash download: Total time needed: 6.157s (Prepare: 0.022s, Compare: 0.081s, Erase: 4.931s, Program: 1.116s, Verify: 0.000s, Restore: 0.005s)
J-Link: Flash download: Restarting flash programming due to program error (possibly skipped erasure of half-way erased sector).
J-Link: Flash download: Skip optimizations disabled for second try.
Error while programming flash: Programming failed.
J-Link>verifybin C:\Users\User\workspace_10\DC_Booster_F756\Debug\DC_Booster_F756.bin,0x08020000
Loading binary file C:\Users\User\workspace_10\DC_Booster_F756\Debug\DC_Booster_F756.bin
Reading 546556 bytes data from target memory @ 0x08020000.
Verify failed @ address 0x08065522.
Expected FE read 00J-Link>

Body:
I reached over to the guys at Segger and they created a wiki page detailing how to resolve the issue. To make the Jlink aware of the Dual Bank config on STM32F7 devices, Jlink Open Flash loader must be used with custom script containing info of the Dual Bank config. Once that's done, the Jlink debugger has no problem when the program jumps from bootloader to main app. Here are the steps for getting Jlink to work with STM32F765VI operating in Dual Bank mode.

First off, use the latest version  from 616f onwards

download and place the precompiled binary (ST STM32F7xxxx_2MB_DualBank.elf)from Jlink wiki to folder containing Jlink.exe and JLinkDevices.xml

edit JLinkDevices.xml to contain info related to the MCU and direct it to use the precompiled binary instead of the default one in Jlink. Add the following beneath the database tag at the start:
<!-- This entry will overwrite the existing device entry in the J-Link software, so that a custom flash algorithm is used for the internal flash -->
<Device>

<ChipInfo Vendor="ST" Name="STM32F765VI" Core="JLINK_CORE_CORTEX_M7" />
<FlashBankInfo Name="Internes Flash" BaseAddr="0x08000000" MaxSize="0x00200000 " Loader="ST_STM32F7xxxx_2MB_DualBank.elf" LoaderType="FLASH_ALGO_TYPE_OPEN" />
</Device>

If you have multiple versions of Jlink installed, make sure you're using the one which has its JLinkDevices.xml edited to use the precompiled binary in your debugging session.


来源: stackexchange

问:
Is there a way to deploy images to Firebase hosting, but only where changes exist?
I deploy my Angular2 site to Firebase hosting, but the 'dist' folder always sends the entire image collection in the 'assets' folder, even if they haven't changed. This takes up more bandwidth than necessary, as this folder is larger than all the other files combined.

How can I deploy ONLY the changed images?
The strategy would be:

A) Configure the Firebase CLI "deploy" command to process only changed images

AND/OR

B) Configure the Angular production build to only package the changed images (though this would still require Firebase to update the 'assets' folder instead of overriding all the other, unchanged images on deployment)

Firebase Storage is not a good alternative as I've seen...making the API calls to access the images on page load only slows down the load time...unless there is a caching strategy involved in this? At the end of the day, the solution needs to involve the CDN and the CLI working together to minimize bandwidth and load/deployment time.

答:
Sorry, there are currently no partial deploys for Firebase Hosting static content.

An alternative might be to host your images in one project and everything else in another project.  If your images don't change very often, then you won't have to deploy to the project with your images if nothing changes.

You could also use Storage to store your images, then serve them via Cloud Functions integration with Firebase Hosting, which can do the lookup dynamically and proxy the image to the client.  Hosting can then be configured to cache the images at the CDN, as described in the documentation.

You might also see some gains if you instead record the Storage download URL for the images in Realtime Database as opposed to asking Storage to generate one, and having the client look there instead.

ContentLicense: CC BY-SA 3.0


问:
Why isn't image size showing in admin?
I have added this code to my themes functions.php

```<code>// Image sizes
add_image_size( 'wide-thumb', 180,125);

add_filter( 'image_size_names_choose', 'dsbjj_my_custom_sizes' );

function dsbjj_my_custom_sizes( $sizes ) {
    return array_merge( $sizes, array(
        'wide-thumb' => __( 'Wide Thumbnail' ),
    ) );
}
</code>```

When I got to edit an image in the media library I cannot see "wide-thumb".  I have tried running regenerate thumbnails but no joy.

What did I do wrong?

答:
A lot of time has passed, but I was having the same issue tonight and found a solution. Instead of

```<code>add_filter( 'image_size_names_choose', 'dsbjj_my_custom_sizes' );

function dsbjj_my_custom_sizes( $sizes ) {
    return array_merge( $sizes, array(
        'wide-thumb' => __( 'Wide Thumbnail' ),
    ) );
}
</code>```

I had to refactor my code to pass my function as the second parameter to add_filter, like so:

```<code>add_filter( 'image_size_names_choose', function ( $sizes ) {
    return array_merge( $sizes, array(
        'wide-thumb' => __( 'Wide Thumbnail' ),
    ) );
} );
</code>```

I came up with this solution after right-clicking the empty 'Size' dropdown on the Media select screen and choosing 'Inspect Element', which allowed me to see the error. I'm not sure if changes in WordPress or my host (Site5) caused the issue, but I hope this answer will help someone.

Title: Why isn't image size showing in admin?

Body:
I have added this code to my themes functions.php

// Image sizes
add_image_size( 'wide-thumb', 180,125);

add_filter( 'image_size_names_choose', 'dsbjj_my_custom_sizes' );

function dsbjj_my_custom_sizes( $sizes ) {
    return array_merge( $sizes, array(
        'wide-thumb' => __( 'Wide Thumbnail' ),
    ) );
}

When I got to edit an image in the media library I cannot see "wide-thumb".  I have tried running regenerate thumbnails but no joy.

What did I do wrong?

Body:
A lot of time has passed, but I was having the same issue tonight and found a solution. Instead of

add_filter( 'image_size_names_choose', 'dsbjj_my_custom_sizes' );

function dsbjj_my_custom_sizes( $sizes ) {
    return array_merge( $sizes, array(
        'wide-thumb' => __( 'Wide Thumbnail' ),
    ) );
}

I had to refactor my code to pass my function as the second parameter to add_filter, like so:

add_filter( 'image_size_names_choose', function ( $sizes ) {
    return array_merge( $sizes, array(
        'wide-thumb' => __( 'Wide Thumbnail' ),
    ) );
} );

I came up with this solution after right-clicking the empty 'Size' dropdown on the Media select screen and choosing 'Inspect Element', which allowed me to see the error. I'm not sure if changes in WordPress or my host (Site5) caused the issue, but I hope this answer will help someone.


问:
How to check entering number in edittext after decimal is only 5 or 0
I want to check length of entered number while entering the value in edittext. Also i want to check user can only able to enter 5 or 0 after decimal point.

Thanks

答:
You should use TextWatcher.  Use this documentation.https://developer.android.com/reference/android/text/TextWatcher.html

Then in OnTextChanged you can check what the length of the edit text is. I don't know how to check if the decimal point ends with 0 or 5. Sorry about that. You should ask a separate question about that. Hope this helps.


问:
overload operator new(), why constructor is called twice?
I can`t understand some problems when learning new/delete overload.
Questions:

Why new is called before constructor，destructor before delete?

Why constructor is called twice when using ::new ?

I've appended the code here:

```<code>#include<iostream>

using namespace std;

class MyClass
{
public:
    MyClass() {
        cout << "My Class is Constructed ！" << endl;

    }

    ~MyClass() { cout << "My Class is Deleted ! " << endl; }

     static void *operator new(size_t Size)
    {
        cout << "new call" << endl;
        MyClass *p = ::new MyClass;
        return p;
     }
     static void operator delete(void *p)
     {
         cout << "delete call" << endl;
         ::delete p;
     }

};
int main()
{
    MyClass  *p = new MyClass;
    delete p;
    cin.get();
    return 0;
}
</code>```

```<code>output:
new call
My Class is Constructed ！
My Class is Constructed ！
My Class is Deleted !
delete call
</code>```

答:
The reason why this is happening is because when you allocate something with new, the allocation and construction happens in two phases.  The first is the actual allocation and the second is construction via placement new.

The overload you have provided is just for allocating memory (hence the size_t parameter), but instead you called new on the class which will do both steps from above.  You should only allocate the memory in that function.  So change your function to be

```<code>static void *operator new(size_t size)
{
   return ::operator new(size);
}
</code>```

And you will see the class being constructed only once.

Body:
I can`t understand some problems when learning new/delete overload.
Questions:

Why new is called before constructor，destructor before delete?

Why constructor is called twice when using ::new ?

I've appended the code here:

#include<iostream>

using namespace std;

class MyClass
{
public:
    MyClass() {
        cout << "My Class is Constructed ！" << endl;

    }

    ~MyClass() { cout << "My Class is Deleted ! " << endl; }

     static void *operator new(size_t Size)
    {
        cout << "new call" << endl;
        MyClass *p = ::new MyClass;
        return p;
     }
     static void operator delete(void *p)
     {
         cout << "delete call" << endl;
         ::delete p;
     }

};
int main()
{
    MyClass  *p = new MyClass;
    delete p;
    cin.get();
    return 0;
}

output:
new call
My Class is Constructed ！
My Class is Constructed ！
My Class is Deleted !
delete call

Body:
The reason why this is happening is because when you allocate something with new, the allocation and construction happens in two phases.  The first is the actual allocation and the second is construction via placement new.

The overload you have provided is just for allocating memory (hence the size_t parameter), but instead you called new on the class which will do both steps from above.  You should only allocate the memory in that function.  So change your function to be

static void *operator new(size_t size)
{
   return ::operator new(size);
}

And you will see the class being constructed only once.


问:
MPI error due to Timeout in making connection to a remote process
I'm trying to run a NAS-UPC benchmark to study it's profile. UPC uses MPI to communicate with remote processes .

When I run the benchmark with 64 processes , i get the following error

```<code>upcrun -n 64 bt.C.64
"Timeout in making connection to remote process on <<machine name>>"
</code>```

Can anybody tell me why this error occurs ?

答:
this probably means that you're failing to spawn the remote processes - upcrun delegates that to a per-conduit mechanism, which may involve your scheduler (if any).  my guess is that you're depending on ssh-type remote access, and that's failing, probably because you don't have keys, agent or host-based trust set up.  can you ssh to your remote nodes without password?  sane environment on the remote nodes (paths, etc)?

"upcrun -v" may illuminate the problem, even without resorting to the man page ;)

ContentLicense: CC BY-SA 2.5

Body:
I'm trying to run a NAS-UPC benchmark to study it's profile. UPC uses MPI to communicate with remote processes .

When I run the benchmark with 64 processes , i get the following error

upcrun -n 64 bt.C.64
"Timeout in making connection to remote process on <<machine name>>"

Can anybody tell me why this error occurs ?


问:
How to fix Country-State-Select gem undefined method issue?
In a implementation of gem:  https://github.com/arvindvyas/Country-State-Select

When i go to Post Job new page show this error on the log

```<code>undefined method `country' for #<Job:0x007f8c07092320>
</code>```

I've tried to put the

```<code>accepts_nested_attributes_for
</code>```

in the job model, but did not worked.

Someone have any hint to spare?

Job Model

```<code>class Job < ActiveRecord::Base
  belongs_to :user
  belongs_to :location
  accepts_nested_attributes_for :location, allow_destroy: true
  default_scope -> { order(created_at: :desc) }
end
</code>```

Location Model

```<code>class Location < ActiveRecord::Base
  has_many :users
  has_many :jobs
end
</code>```

Job new view

```<code><%= simple_form_for @job do |f| %>
  <%= f.simple_fields_for :location do |l| %>
    <%= l.input :country, label: "Country", collection: CountryStateSelect.countries_collection %>
    <%= l.input :state, CountryStateSelect.state_options(label: "State / Province", form: f, field_names: { :country => :country, :state => :state } ) %>
    <%= l.input :city, CountryStateSelect.city_options(label: "City ", form: f, field_names: {  :state => :state, :city => :city } ) %>
  <% end %>
  <%= f.input :name, label: 'Name', error: 'Name is mandatory' %>
  <%= f.input :description, placeholder: 'user@domain.com' %>
  <%= f.button :submit %>
<% end %>
</code>```

答:
In the fields

```<code><%= l.input :state, CountryStateSelect.state_options(label: "State / Province", form: f, field_names: { :country => :country, :state => :state } ) %>
<%= l.input :city, CountryStateSelect.city_options(label: "City ", form: f, field_names: {  :state => :state, :city => :city } ) %>
</code>```

you have form: f, but you are within a simple_fields_for block which is currently using l instead of f

Body:
In a implementation of gem:  https://github.com/arvindvyas/Country-State-Select

When i go to Post Job new page show this error on the log

undefined method `country' for #<Job:0x007f8c07092320>

I've tried to put the

accepts_nested_attributes_for

in the job model, but did not worked.

Someone have any hint to spare?

Job Model

class Job < ActiveRecord::Base
  belongs_to :user
  belongs_to :location
  accepts_nested_attributes_for :location, allow_destroy: true
  default_scope -> { order(created_at: :desc) }
end

Location Model

class Location < ActiveRecord::Base
  has_many :users
  has_many :jobs
end

Job new view

<%= simple_form_for @job do |f| %>
  <%= f.simple_fields_for :location do |l| %>
    <%= l.input :country, label: "Country", collection: CountryStateSelect.countries_collection %>
    <%= l.input :state, CountryStateSelect.state_options(label: "State / Province", form: f, field_names: { :country => :country, :state => :state } ) %>
    <%= l.input :city, CountryStateSelect.city_options(label: "City ", form: f, field_names: {  :state => :state, :city => :city } ) %>
  <% end %>
  <%= f.input :name, label: 'Name', error: 'Name is mandatory' %>
  <%= f.input :description, placeholder: 'user@domain.com' %>
  <%= f.button :submit %>
<% end %>

Body:
In the fields

<%= l.input :state, CountryStateSelect.state_options(label: "State / Province", form: f, field_names: { :country => :country, :state => :state } ) %>
<%= l.input :city, CountryStateSelect.city_options(label: "City ", form: f, field_names: {  :state => :state, :city => :city } ) %>

you have form: f, but you are within a simple_fields_for block which is currently using l instead of f


问:
How to output JSON for WordPress search page using Relevanssi?
I'm using the WordPress search plugin Relevanssi.

I'm trying to customise my search.php template to output JSON, like so:

```<code><?php

header('Content-Type: application/json');

$results = array();

if (have_posts()):
  while (have_posts()):
    the_post();
    $results[] = array(
      'permalink' => get_permalink(),
      'title' => get_the_title()
    );
  endwhile;
endif;

echo json_encode($results);

die();

?>
</code>```

However, I'm getting an error that headers are already sent.

Warning: Cannot modify header information - headers already sent by
  (output started at
  /Applications/MAMP/htdocs/NBC/wp-content/plugins/relevanssi/lib/search.php:554)
  in /Applications/MAMP/htdocs/NBC/wp-content/themes/NBC/search.php on
  line 3

Is there a better way to do this? The reason I need it as JSON is that I want to consume it with JS.

I have done this before on an older site, so perhaps the issues are with the latest version I'm using? 3.5.11

Note that the query DOES return results, but I get these errors on the page too, which causes me to receive invalid JSON data back.

Thanks!

答:
Relevanssi 3.5.11 has a small bug. It doesn't affect the plugin use in any way, but with WP_DEBUG enabled, it throws a notice for an undefined variable. That's why you're seeing that "headers already sent" error.

If you want to keep WP_DEBUG enabled, you need to fix that bug. The fix is simple: add this to lib/search.php on line 382 to define the variable.

$non_post_post_type = NULL;

This fix will be included in the version 3.5.12.

Body:
I'm using the WordPress search plugin Relevanssi.

I'm trying to customise my search.php template to output JSON, like so:

<?php

header('Content-Type: application/json');

$results = array();

if (have_posts()):
  while (have_posts()):
    the_post();
    $results[] = array(
      'permalink' => get_permalink(),
      'title' => get_the_title()
    );
  endwhile;
endif;

echo json_encode($results);

die();

?>

However, I'm getting an error that headers are already sent.

Warning: Cannot modify header information - headers already sent by
  (output started at
  /Applications/MAMP/htdocs/NBC/wp-content/plugins/relevanssi/lib/search.php:554)
  in /Applications/MAMP/htdocs/NBC/wp-content/themes/NBC/search.php on
  line 3

Is there a better way to do this? The reason I need it as JSON is that I want to consume it with JS.

I have done this before on an older site, so perhaps the issues are with the latest version I'm using? 3.5.11

Note that the query DOES return results, but I get these errors on the page too, which causes me to receive invalid JSON data back.

Thanks!


问:
Database design to manage data from Serial Port?
I'm writing codes to capture Serial Port data (e.g. micrometer) and do the following

real time display and graphing

delete/modify/replace existing data by focus and re-measurement,

save data somewhere for additional statistical analysis (e.g. in Excel).  So out put as .csv is also an option

Because each measurement may capture hundreds to thousands of data (measurement points), I'm not sure how shall go about to design my database - shall I create a new row for each data received, or shall I push all data into an array and store as a super long string separated by a comma into the database? For such application, do I need Server 2008 or would Server 2008 Express will be sufficient. What are their pros/cons in terms of performance?

Is it possible to create such as application where client won't need to install sql server?

答:
If you decide that the giant string approach makes sense for your application, you would probably just be better off using text files.  Relational databases provide benefit only when your data is structured.  If you go with a database it should be because you are storing discreet values in rows and columns.

An out of process database strikes me as a mismatch for this project.  Have you considered SQLite or some other compile-or-link in solution?  You'll probably get faster throughput of those large measurement vectors with something that runs in process.


问:
Concrete JavaScript regular expression for accented characters (diacritics)
I've looked on Stack Overflow (replacing characters.. eh, how JavaScript doesn't follow the Unicode standard concerning RegExp, etc.) and haven't really found a concrete answer to the question "How can JavaScript match accented characters (those with diacritical marks)?"

I'm forcing a field in a UI to match the format: last_name, first_name (last [comma space] first), and I want to provide support for diacritics, but evidently in JavaScript it's a bit more difficult than other languages/platforms.

This was my original version, until I wanted to add diacritic support:

/^[a-zA-Z]+,\s[a-zA-Z]+$/

Currently I'm debating one of three methods to add support, all of which I have tested and work (at least to some extent, I don't really know what the "extent" is of the second approach). Here they are:

Explicitly listing all accented characters that I would want to accept as valid (lame and overly-complicated):

```<code>var accentedCharacters = "àèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸçÇßØøÅåÆæœ";
// Build the full regex
var regex = "^[a-zA-Z" + accentedCharacters + "]+,\\s[a-zA-Z" + accentedCharacters + "]+$";
// Create a RegExp from the string version
regexCompiled = new RegExp(regex);
// regexCompiled = /^[a-zA-ZàèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸçÇßØøÅåÆæœ]+,\s[a-zA-ZàèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸçÇßØøÅåÆæœ]+$/
</code>```

This correctly matches a last/first name with any of the supported accented characters in accentedCharacters.

My other approach was to use the . character class, to have a simpler expression:

```<code>var regex = /^.+,\s.+$/;
</code>```

This would match for just about anything, at least in the form of: something, something. That's alright I suppose...

The last approach, which I just found might be simpler...

```<code>/^[a-zA-Z\u00C0-\u017F]+,\s[a-zA-Z\u00C0-\u017F]+$/
</code>```

It matches a range of Unicode characters - tested and working, though I didn't try anything crazy, just the normal stuff I see in our language department for faculty member names.

Here are my concerns:

The first solution is far too limiting, and sloppy and convoluted at that. It would need to be changed if I forgot a character or two, and that's just not very practical.

The second solution is better, concise, but it probably matches far more than it actually should. I couldn't find any real documentation on exactly what . matches, just the generalization of "any character except the newline character" (from a table on the MDN).

The third solution seems the be the most precise, but are there any gotchas? I'm not very familiar with Unicode, at least in practice, but looking at a code table/continuation of that table, \u00C0-\u017F seems to be pretty solid, at least for my expected input.

Faculty won't be submitting forms with their names in their native language (e.g., Arabic, Chinese, Japanese, etc.), so I don't have to worry about out-of-Latin-character-set characters

Which of these three approaches is most suited for the task? Or are there better solutions?

答:
You can use this:</p>
```<code>/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I've looked on Stack Overflow (replacing characters.. eh, how JavaScript doesn't follow the Unicode standard concerning RegExp, etc.) and haven't really found a concrete answer to the question "How can JavaScript match accented characters (those with diacritical marks)?"

I'm forcing a field in a UI to match the format: last_name, first_name (last [comma space] first), and I want to provide support for diacritics, but evidently in JavaScript it's a bit more difficult than other languages/platforms.

This was my original version, until I wanted to add diacritic support:

/^[a-zA-Z]+,\s[a-zA-Z]+$/

Currently I'm debating one of three methods to add support, all of which I have tested and work (at least to some extent, I don't really know what the "extent" is of the second approach). Here they are:

Explicitly listing all accented characters that I would want to accept as valid (lame and overly-complicated):

var accentedCharacters = "àèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸçÇßØøÅåÆæœ";
// Build the full regex
var regex = "^[a-zA-Z" + accentedCharacters + "]+,\\s[a-zA-Z" + accentedCharacters + "]+$";
// Create a RegExp from the string version
regexCompiled = new RegExp(regex);
// regexCompiled = /^[a-zA-ZàèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸçÇßØøÅåÆæœ]+,\s[a-zA-ZàèìòùÀÈÌÒÙáéíóúýÁÉÍÓÚÝâêîôûÂÊÎÔÛãñõÃÑÕäëïöüÿÄËÏÖÜŸçÇßØøÅåÆæœ]+$/

This correctly matches a last/first name with any of the supported accented characters in accentedCharacters.

My other approach was to use the . character class, to have a simpler expression:

var regex = /^.+,\s.+$/;

This would match for just about anything, at least in the form of: something, something. That's alright I suppose...

The last approach, which I just found might be simpler...

/^[a-zA-Z\u00C0-\u017F]+,\s[a-zA-Z\u00C0-\u017F]+$/

It matches a range of Unicode characters - tested and working, though I didn't try anything crazy, just the normal stuff I see in our language department for faculty member names.

Here are my concerns:

The first solution is far too limiting, and sloppy and convoluted at that. It would need to be changed if I forgot a character or two, and that's just not very practical.

The second solution is better, concise, but it probably matches far more than it actually should. I couldn't find any real documentation on exactly what . matches, just the generalization of "any character except the newline character" (from a table on the MDN).

The third solution seems the be the most precise, but are there any gotchas? I'm not very familiar with Unicode, at least in practice, but looking at a code table/continuation of that table, \u00C0-\u017F seems to be pretty solid, at least for my expected input.

Faculty won't be submitting forms with their names in their native language (e.g., Arabic, Chinese, Japanese, etc.), so I don't have to worry about out-of-Latin-character-set characters

Which of these three approaches is most suited for the task? Or are there better solutions?

Body:
You can use this:

/^[a-zA-ZÀ-ÖØ-öø-ÿ]+$/


问:
set cursor position DIV fixed center-bottom to target
my questions is How to show div or box element with position fixed center-bottom to click target

example :

```<code><p>
  <button class="target-show">target show</button>
  <button class="target-show">target show</button>
</p>

<hr><hr><hr><hr><hr><hr><hr>
<hr><hr><hr><hr><hr><hr><hr>

<div id="demo"></div>

<p>
  <button class="hidden-div">hidden div</button>
</p>
</code>```

css :

```<code>p {
  text-align:center;
}
button {
  width : 50px;
}
#demo {
  display :none;
  padding : 25px;
  background : red ;
  width : 100px;
  height : 100px;
}
</code>```

jquery :

```<code>$(function() {
    $(".target-show").click(function(e) {
        var target  =   $('.target-show');
            var div         =   $('#demo');
      var left      = e.clientX - target.width()/2;
      var top       = e.clientY - target.height()/2;
        div.css({'position': 'absolute', 'left': left, 'top': top}).show();
    });

      $(".hidden-div").click(function() {
                $("#demo").hide();
        });
});
</code>```

$(function() {
    $(".target-show").click(function(e) {
     var target = $('.target-show');
   var div   = $('#demo');
      var left  = e.clientX - target.width()/2;
      var top   = e.clientY - target.height()/2;
        div.css({'position': 'absolute', 'left': left, 'top': top}).show();
    });

      $(".hidden-div").click(function() {
       $("#demo").hide();
     });
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>p {
  text-align:center;
}

button {
  width : 50px;
}

#demo {
  display :none;
  padding : 25px;
  background : red ;
  width : 100px;
  height : 100px;
}</code>```

  <button class="target-show">target show</button>
  <button class="target-show">target show</button>

  <button class="hidden-div">hidden div</button>

```

答:
If you want the red div to appear centered-bottom relative to the mouse pointer when user clicks, you have to use outerWidth() and outerHeight() which is including not only the div width and height, but also the padding:25px from your CSS.

It would also include the border width...

And if you pass a true as argument, it will include the margins.

;)

$(function() {
  $(".target-show").click(function(e) {
    var div   = $('#demo').show();
    var left  = e.clientX - (div.outerWidth()/2);
    var top   = e.clientY - (div.outerHeight());
    div.css({'position': 'absolute', 'left': left, 'top': top}).show();
  });

  $(".hidden-div").click(function() {
    $("#demo").hide();
  });
});```
<pre class="snippet-code-css lang-css prettyprint-override"><code>p {
  text-align:center;
}

button {
  width : 50px;
}

#demo {
  display :none;
  padding : 25px;
  background : red ;
  width : 100px;
  height : 100px;
}</code>```

  <button class="target-show">target show</button>
  <button class="target-show">target show</button>

  <button class="hidden-div">hidden div</button>

```

Body:
my questions is How to show div or box element with position fixed center-bottom to click target

example :

  <button class="target-show">target show</button>
  <button class="target-show">target show</button>

  <button class="hidden-div">hidden div</button>

css :

p {
  text-align:center;
}
button {
  width : 50px;
}
#demo {
  display :none;
  padding : 25px;
  background : red ;
  width : 100px;
  height : 100px;
}

jquery :

$(function() {
    $(".target-show").click(function(e) {
        var target  =   $('.target-show');
            var div         =   $('#demo');
      var left      = e.clientX - target.width()/2;
      var top       = e.clientY - target.height()/2;
        div.css({'position': 'absolute', 'left': left, 'top': top}).show();
    });

      $(".hidden-div").click(function() {
                $("#demo").hide();
        });
});

$(function() {
    $(".target-show").click(function(e) {
     var target = $('.target-show');
   var div   = $('#demo');
      var left  = e.clientX - target.width()/2;
      var top   = e.clientY - target.height()/2;
        div.css({'position': 'absolute', 'left': left, 'top': top}).show();
    });

      $(".hidden-div").click(function() {
       $("#demo").hide();
     });
});

p {
  text-align:center;
}

button {
  width : 50px;
}

#demo {
  display :none;
  padding : 25px;
  background : red ;
  width : 100px;
  height : 100px;
}

  <button class="target-show">target show</button>
  <button class="target-show">target show</button>

  <button class="hidden-div">hidden div</button>

Body:
If you want the red div to appear centered-bottom relative to the mouse pointer when user clicks, you have to use outerWidth() and outerHeight() which is including not only the div width and height, but also the padding:25px from your CSS.

It would also include the border width...

And if you pass a true as argument, it will include the margins.

;)

$(function() {
  $(".target-show").click(function(e) {
    var div   = $('#demo').show();
    var left  = e.clientX - (div.outerWidth()/2);
    var top   = e.clientY - (div.outerHeight());
    div.css({'position': 'absolute', 'left': left, 'top': top}).show();
  });

  $(".hidden-div").click(function() {
    $("#demo").hide();
  });
});

p {
  text-align:center;
}

button {
  width : 50px;
}

#demo {
  display :none;
  padding : 25px;
  background : red ;
  width : 100px;
  height : 100px;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p>
  <button class="target-show">target show</button>
  <button class="target-show">target show</button>
</p>

<hr><hr><hr><hr><hr><hr><hr>
<hr><hr><hr><hr><hr><hr><hr>

<div id="demo"></div>

<p>
  <button class="hidden-div">hidden div</button>
</p>


Title: Lambda with itertools not working

Body:
I want to create a Cartesian product and choose the tuples from second and third position which are equal or differ only by 1

import itertools

a = [(1,4), (2,2), (3,9),(7,4),(5,4)];

a1 = ( list(itertools.product(*a)))

print (a1)
i=a1[1]
k=a1[2]

new_list = list(filter(lambda i,k: (i-k <= 1) , a1))
print (my_list)

But result is

[(1, 2, 3, 7, 5), (1, 2, 3, 7, 4), (1, 2, 3, 4, 5), (1, 2, 3, 4, 4), (1, 2, 9, 7, 5), (1, 2, 9, 7, 4), (1, 2, 9, 4, 5), (1, 2, 9, 4, 4), (1, 2, 3, 7, 5), (1, 2, 3, 7, 4), (1, 2, 3, 4, 5), (1, 2, 3, 4, 4), (1, 2, 9, 7, 5), (1, 2, 9, 7, 4), (1, 2, 9, 4, 5), (1, 2, 9, 4, 4), (4, 2, 3, 7, 5), (4, 2, 3, 7, 4), (4, 2, 3, 4, 5), (4, 2, 3, 4, 4), (4, 2, 9, 7, 5), (4, 2, 9, 7, 4), (4, 2, 9, 4, 5), (4, 2, 9, 4, 4), (4, 2, 3, 7, 5), (4, 2, 3, 7, 4), (4, 2, 3, 4, 5), (4, 2, 3, 4, 4), (4, 2, 9, 7, 5), (4, 2, 9, 7, 4), (4, 2, 9, 4, 5), (4, 2, 9, 4, 4)]

    new_list = list(filter(lambda i,k: (i-k <= 1) , a1))
TypeError: <lambda>() missing 1 required positional argument: 'k'

What is wrong with my lambda?

Body:
import itertools
a =[(1,4),(2,2),(3,9),(7,4),(5,4)]
b = itertools.product(*a)
c = filter(lambda x: abs(x[1]-x[2])<=1, b)
print(c)

gives (edited for visibility)

[(1, 2, 3, 7, 5),
 (1, 2, 3, 7, 4),
 (1, 2, 3, 4, 5),
 (1, 2, 3, 4, 4),
 (1, 2, 3, 7, 5),
 (1, 2, 3, 7, 4),
 (1, 2, 3, 4, 5),
 (1, 2, 3, 4, 4),
 (4, 2, 3, 7, 5),
 (4, 2, 3, 7, 4),
 (4, 2, 3, 4, 5),
 (4, 2, 3, 4, 4),
 (4, 2, 3, 7, 5),
 (4, 2, 3, 7, 4),
 (4, 2, 3, 4, 5),
 (4, 2, 3, 4, 4)]


问:
Adding a User-Defined Function to Calcite
I need to add a user-defined function to Calcite that takes an integer as a parameter and returns an integer.

```<code>    public class SquareFunction  {
        public int eval(int a) {
            return a*a;
        }
    }
</code>```

and the relevant code that creates a schema and adds the function is

```<code>     SchemaPlus rootSchema = Frameworks.createRootSchema(false);
     rootSchema.add("SQUARE_FUNC",
                    ScalarFunctionImpl.create(SquareFunction.class,"eval");
</code>```

But a simple SQL like

```<code>select SQUARE_FUNC(1) from test;
</code>```

fails during the validation with the following message:

```<code>No match found for function signature SQUARE_FUNC(<NUMERIC>)
</code>```

The stack trace is:

```<code>at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463)
    at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:804)
    at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:789)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4386)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1670)
    at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:278)
    at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:223)
    at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:4965)
    at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:1)
    at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:137)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1586)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1571)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:453)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:3668)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3186)
    at org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
    at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:937)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:918)
    at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:220)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:893)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:603)
    at org.apache.calcite.prepare.PlannerImpl.validate(PlannerImpl.java:188) ... 26 more
</code>```

I followed the Calcite's UdfTest.testUserDefinedFunctionInView implementation but still couldn't make it work. What am I doing wrong?

答:
How does Calcite validates that a function exists?

As I known, SqlOperatorTable defines a directory interface for enumerating and looking up SQL operators and functions, and lookupOperatorOverloads retrieves a list of operators with a given name and syntax.

For the Frameworks, the default SqlOperatorTable of FrameworkConfig is SqlStdOperatorTable.instance(). But the function you added only searched at CalciteCatalogReader. So following code can work:

```<code>   public class UdfTest {
    private static final String SQL      = "select SQUARE_FUNC(1)";
    private static final String FUN_NAME = "SQUARE_FUNC";

    public static void main(String[] args) throws Exception {
        useFramworksExec();
    }

    private static void useFramworksExec() throws Exception {
        CalciteSchema rootSchema = CalciteSchema.createRootSchema(false, false);
        SchemaPlus schema = rootSchema.plus();
        schema.add(FUN_NAME, ScalarFunctionImpl.create(SquareFunction.class, "eval"));
        CalciteCatalogReader reader = new CalciteCatalogReader(rootSchema,
            SqlParser.Config.DEFAULT.caseSensitive(),
            rootSchema.path(null),
            new JavaTypeFactoryImpl());
        FrameworkConfig config = Frameworks.newConfigBuilder().operatorTable(reader).defaultSchema(schema).build();
        Planner planner = Frameworks.getPlanner(config);
        SqlNode ast = planner.parse(SQL);
        SqlNode validatedAst = planner.validate(ast);
        System.out.println(validatedAst.toString());
    }
}
</code>```

Body:
I need to add a user-defined function to Calcite that takes an integer as a parameter and returns an integer.

    public class SquareFunction  {
        public int eval(int a) {
            return a*a;
        }
    }

and the relevant code that creates a schema and adds the function is

     SchemaPlus rootSchema = Frameworks.createRootSchema(false);
     rootSchema.add("SQUARE_FUNC",
                    ScalarFunctionImpl.create(SquareFunction.class,"eval");

But a simple SQL like

select SQUARE_FUNC(1) from test;

fails during the validation with the following message:

No match found for function signature SQUARE_FUNC(<NUMERIC>)

The stack trace is:

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
    at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463)
    at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:804)
    at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:789)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4386)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.handleUnresolvedFunction(SqlValidatorImpl.java:1670)
    at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:278)
    at org.apache.calcite.sql.SqlFunction.deriveType(SqlFunction.java:223)
    at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:4965)
    at org.apache.calcite.sql.validate.SqlValidatorImpl$DeriveTypeVisitor.visit(SqlValidatorImpl.java:1)
    at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:137)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveTypeImpl(SqlValidatorImpl.java:1586)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.deriveType(SqlValidatorImpl.java:1571)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.expandSelectItem(SqlValidatorImpl.java:453)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelectList(SqlValidatorImpl.java:3668)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3186)
    at org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
    at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:937)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:918)
    at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:220)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:893)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:603)
    at org.apache.calcite.prepare.PlannerImpl.validate(PlannerImpl.java:188) ... 26 more

I followed the Calcite's UdfTest.testUserDefinedFunctionInView implementation but still couldn't make it work. What am I doing wrong?

Body:
How does Calcite validates that a function exists?

As I known, SqlOperatorTable defines a directory interface for enumerating and looking up SQL operators and functions, and lookupOperatorOverloads retrieves a list of operators with a given name and syntax.

For the Frameworks, the default SqlOperatorTable of FrameworkConfig is SqlStdOperatorTable.instance(). But the function you added only searched at CalciteCatalogReader. So following code can work:

   public class UdfTest {
    private static final String SQL      = "select SQUARE_FUNC(1)";
    private static final String FUN_NAME = "SQUARE_FUNC";

    public static void main(String[] args) throws Exception {
        useFramworksExec();
    }

    private static void useFramworksExec() throws Exception {
        CalciteSchema rootSchema = CalciteSchema.createRootSchema(false, false);
        SchemaPlus schema = rootSchema.plus();
        schema.add(FUN_NAME, ScalarFunctionImpl.create(SquareFunction.class, "eval"));
        CalciteCatalogReader reader = new CalciteCatalogReader(rootSchema,
            SqlParser.Config.DEFAULT.caseSensitive(),
            rootSchema.path(null),
            new JavaTypeFactoryImpl());
        FrameworkConfig config = Frameworks.newConfigBuilder().operatorTable(reader).defaultSchema(schema).build();
        Planner planner = Frameworks.getPlanner(config);
        SqlNode ast = planner.parse(SQL);
        SqlNode validatedAst = planner.validate(ast);
        System.out.println(validatedAst.toString());
    }
}


问:
React+Redux - Uncaught Error: Expected the reducer to be a function
I tried simple react,redux,ajax working example and followed Reddit API tutorial, but I cannot create store and get error:

```<code>Uncaught Error: Expected the reducer to be a function.
</code>```

index.jsx

...

```<code>import { createStore, applyMiddleware } from 'redux'
var thunkMiddleware = require('redux-thunk');
var createLogger = require('redux-logger');
var rootReducer = require('./reducers.js');

        const loggerMiddleware = createLogger();

        function configureStore(initialState) {
            return createStore(
                rootReducer,
                initialState,
                applyMiddleware(
                    thunkMiddleware,
                    loggerMiddleware
                )
            )
        }

        const store = configureStore();
</code>```

...

rootReducer.js

```<code>import { combineReducers } from 'redux';

function products(state = {
    isFetching: false,
    didInvalidate: false,
    items: []
}, action) {
    switch (action.type) {
        case 'REQUEST_PRODUCTS':
            return Object.assign({}, state, {
                isFetching: true,
                didInvalidate: false
            })
        case 'RECEIVE_PRODUCTS':
            return Object.assign({}, state, {
                isFetching: false,
                didInvalidate: false,
                items: action.posts,
                lastUpdated: action.receivedAt
            })
        default:
            return state
    }
}

function specialPosts(state = { }, action) {
    switch (action.type) {
        case RECEIVE_SPECPOSTS:
        case REQUEST_SPECPOSTS:
            return Object.assign({}, state, {
                req: true
            })
        default:
            return state
    }
}

const rootReducer = combineReducers({
    products,
    specialPosts
});

export default rootReducer;
</code>```

Type of rootReducer is object, but why? Should I change createStore function to rootReducer.default?

```<code>return createStore(
    rootReducer.default,
    initialState,
    applyMiddleware(
        thunkMiddleware,
        loggerMiddleware
     )
)
</code>```

package.json

```<code>"redux-logger": "^2.6.1",
"react-redux": "^4.4.1",
"react-redux-provide": "^5.2.3",
"redux": "^3.3.1",
"redux-thunk": "^2.0.1",
</code>```

答:
rootReducer

```<code>/* index.js */

import AppReducer from './reducers';
// import {AppReducer} from './reducers';
// bugs : must be a root reducer, can not be use as a module

/* reducers.js */

// initial state
const initialState = {
    angular: 0,
    react: 0,
    vuejs: 0
};

// reducers update state
const AppReducers = (state = initialState, action) => {
    switch (action.type) {
        case 'VOTE_ANGULAR':
            console.log("Vote Angular!");
            return (
                Object.assign(
                    {},
                    state,
                    {
                        angular: state.angular + 1
                    }
                )
            );
        case 'VOTE_REACT':
            console.log("Vote React!");
            return (
                Object.assign(
                    {},
                    state,
                    {
                        react: state.react + 1
                    }
                )
            );
        case 'VOTE_VUEJS':
            console.log("Vote Vue.jsc!");
            return (
                Object.assign(
                    {},
                    state,
                    {
                        vuejs: state.vuejs + 1
                    }
                )
            );
        default:
            return state;
    }
};

export {AppReducers};
export default AppReducers;
</code>```

Body:
I tried simple react,redux,ajax working example and followed Reddit API tutorial, but I cannot create store and get error:

Uncaught Error: Expected the reducer to be a function.

index.jsx

...

import { createStore, applyMiddleware } from 'redux'
var thunkMiddleware = require('redux-thunk');
var createLogger = require('redux-logger');
var rootReducer = require('./reducers.js');

        const loggerMiddleware = createLogger();

        function configureStore(initialState) {
            return createStore(
                rootReducer,
                initialState,
                applyMiddleware(
                    thunkMiddleware,
                    loggerMiddleware
                )
            )
        }

        const store = configureStore();

...

rootReducer.js

import { combineReducers } from 'redux';

function products(state = {
    isFetching: false,
    didInvalidate: false,
    items: []
}, action) {
    switch (action.type) {
        case 'REQUEST_PRODUCTS':
            return Object.assign({}, state, {
                isFetching: true,
                didInvalidate: false
            })
        case 'RECEIVE_PRODUCTS':
            return Object.assign({}, state, {
                isFetching: false,
                didInvalidate: false,
                items: action.posts,
                lastUpdated: action.receivedAt
            })
        default:
            return state
    }
}

function specialPosts(state = { }, action) {
    switch (action.type) {
        case RECEIVE_SPECPOSTS:
        case REQUEST_SPECPOSTS:
            return Object.assign({}, state, {
                req: true
            })
        default:
            return state
    }
}

const rootReducer = combineReducers({
    products,
    specialPosts
});

export default rootReducer;

Type of rootReducer is object, but why? Should I change createStore function to rootReducer.default?

return createStore(
    rootReducer.default,
    initialState,
    applyMiddleware(
        thunkMiddleware,
        loggerMiddleware
     )
)

package.json

"redux-logger": "^2.6.1",
"react-redux": "^4.4.1",
"react-redux-provide": "^5.2.3",
"redux": "^3.3.1",
"redux-thunk": "^2.0.1",

Body:
rootReducer

/* index.js */

import AppReducer from './reducers';
// import {AppReducer} from './reducers';
// bugs : must be a root reducer, can not be use as a module

/* reducers.js */

// initial state
const initialState = {
    angular: 0,
    react: 0,
    vuejs: 0
};

// reducers update state
const AppReducers = (state = initialState, action) => {
    switch (action.type) {
        case 'VOTE_ANGULAR':
            console.log("Vote Angular!");
            return (
                Object.assign(
                    {},
                    state,
                    {
                        angular: state.angular + 1
                    }
                )
            );
        case 'VOTE_REACT':
            console.log("Vote React!");
            return (
                Object.assign(
                    {},
                    state,
                    {
                        react: state.react + 1
                    }
                )
            );
        case 'VOTE_VUEJS':
            console.log("Vote Vue.jsc!");
            return (
                Object.assign(
                    {},
                    state,
                    {
                        vuejs: state.vuejs + 1
                    }
                )
            );
        default:
            return state;
    }
};

export {AppReducers};
export default AppReducers;


问:
crash error when execute docker-compose
I executed the command

```<code>docker-compose down
</code>```

and get this error

```<code>Traceback (most recent call last):
File "bin/docker-compose", line 3, in <module>
File "compose/cli/main.py", line 68, in main
File "compose/cli/main.py", line 115, in perform_command
File "compose/cli/command.py", line 37, in project_from_options
File "compose/cli/command.py", line 91, in get_project
File "compose/config/config.py", line 362, in load
File "compose/config/config.py", line 528, in process_config_file
File "compose/config/validation.py", line 378, in
validate_against_config_schema
File "compose/config/validation.py", line 439, in handle_errors
File "compose/config/validation.py", line 439, in <genexpr>
File "compose/config/validation.py", line 365, in
process_config_schema_errors
File "compose/config/validation.py", line 237, in handle_generic_error
File "compose/config/validation.py", line 305, in
_parse_oneof_validator
File "compose/config/validation.py", line 320, in
_parse_oneof_validator
File "compose/config/validation.py", line 285, in
_parse_valid_types_from_validator
 File "compose/config/validation.py", line 201, in anglicize_json_type
e
AttributeError: 'bool' object has no attribute 'startswith'
Failed to execute script docker-compose
</code>```

I don't know what happened, everything was ok yesterday then just goes wrong today without any reasons.

```<code>Docker version 17.06.0-ce, build 02c1d87
docker-compose version 1.14.0, build c7bdf9
</code>```

答:
finally, solved the problem. but unfortunately, I don't know exactly what i did.
I executed this command:

```<code>pip freeze | grep docker
</code>```

and saw that i have docker, docker-compose, docker-py packages in Python, but i still have docker, docker-compose in the system (Ubuntu). Perhaps they caused some conflicts somewhere.
So I uninstall all docker, docker-related-packages in python.

After that, I stop all containers running in docker (not using docker-compose down anymore, I used some command found on the internet), remove almost containers' config, and run docker-compose up again. It works.

So I add perspective containers' config, when adding Nginx container's config to docker-compose.yml, the problem appeared again. So I changed in  nginx's config and the problem was solved

Title: crash error when execute docker-compose

Body:
I executed the command

docker-compose down

and get this error

Traceback (most recent call last):
File "bin/docker-compose", line 3, in <module>
File "compose/cli/main.py", line 68, in main
File "compose/cli/main.py", line 115, in perform_command
File "compose/cli/command.py", line 37, in project_from_options
File "compose/cli/command.py", line 91, in get_project
File "compose/config/config.py", line 362, in load
File "compose/config/config.py", line 528, in process_config_file
File "compose/config/validation.py", line 378, in
validate_against_config_schema
File "compose/config/validation.py", line 439, in handle_errors
File "compose/config/validation.py", line 439, in <genexpr>
File "compose/config/validation.py", line 365, in
process_config_schema_errors
File "compose/config/validation.py", line 237, in handle_generic_error
File "compose/config/validation.py", line 305, in
_parse_oneof_validator
File "compose/config/validation.py", line 320, in
_parse_oneof_validator
File "compose/config/validation.py", line 285, in
_parse_valid_types_from_validator
 File "compose/config/validation.py", line 201, in anglicize_json_type
e
AttributeError: 'bool' object has no attribute 'startswith'
Failed to execute script docker-compose

I don't know what happened, everything was ok yesterday then just goes wrong today without any reasons.

Docker version 17.06.0-ce, build 02c1d87
docker-compose version 1.14.0, build c7bdf9

Body:
finally, solved the problem. but unfortunately, I don't know exactly what i did.
I executed this command:

pip freeze | grep docker

and saw that i have docker, docker-compose, docker-py packages in Python, but i still have docker, docker-compose in the system (Ubuntu). Perhaps they caused some conflicts somewhere.
So I uninstall all docker, docker-related-packages in python.

After that, I stop all containers running in docker (not using docker-compose down anymore, I used some command found on the internet), remove almost containers' config, and run docker-compose up again. It works.

So I add perspective containers' config, when adding Nginx container's config to docker-compose.yml, the problem appeared again. So I changed in  nginx's config and the problem was solved


问:
Getting directory listing over http
There is a directory that is being served over the net which I'm interested in monitoring. Its contents are various versions of software that I'm using and I'd like to write a script that I could run which checks what's there, and downloads anything that is newer that what I've already got.

Is there a way, say with wget or something, to get a a directory listing. I've tried using wget on the directory, which gives me html. To avoid having to parse the html document, is there a way of retrieving a simple listing like ls would give?

答: If it's being served by http then there's no way to get a simple directory listing. The listing you see when you browse there, which is the one wget is retrieving, is generated by the web server as an HTML page. All you can do is parse that page and extract the information.</p>

Title: Getting directory listing over http